确保布局总是相同的大小

时间:2013-05-24 09:05:14

标签: android android-layout xamarin.android

我正在开发一个消息传递应用程序并且遇到了一个小问题,但却非常讨厌。我通过引入布局然后膨胀来动态渲染消息。这部分工作正常。问题是说我的消息短于另一条消息,较小的消息不保留布局以确保它与较大的消息大小相同。

我的布局文件如下所示

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="horizontal"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="fill_parent"
p1:layout_height="fill_parent"
p1:id="@+id/linearLayout1">
<LinearLayout
    p1:orientation="horizontal"
    p1:minWidth="25px"
    p1:minHeight="25px"
    p1:layout_width="fill_parent"
    p1:layout_height="wrap_content"
    p1:id="@+id/linearLayout9"
    p1:weightSum="1">
    <LinearLayout
        p1:orientation="vertical"
        p1:minWidth="25px"
        p1:minHeight="25px"
        p1:layout_width="wrap_content"
        p1:layout_height="fill_parent"
        p1:id="@+id/linearLayout10"
        p1:layout_weight=".15" />
    <LinearLayout
        p1:orientation="vertical"
        p1:minWidth="25px"
        p1:minHeight="25px"
        p1:layout_width="match_parent"
        p1:layout_height="fill_parent"
        p1:id="@+id/linearLayout11"
        p1:layout_weight=".7"
        p1:weightSum="1"
        p1:background="@drawable/border">
        <LinearLayout
            p1:orientation="horizontal"
            p1:minWidth="25px"
            p1:minHeight="25px"
            p1:id="@+id/linearLayout2"
            p1:layout_width="match_parent"
            p1:layout_height="wrap_content"
            p1:weightSum="1">
            <LinearLayout
                p1:orientation="vertical"
                p1:minWidth="25px"
                p1:minHeight="25px"
                p1:layout_width="match_parent"
                p1:layout_height="fill_parent"
                p1:id="@+id/linearLayout3">
                <TableLayout
                    p1:minWidth="25px"
                    p1:minHeight="25px"
                    p1:layout_width="fill_parent"
                    p1:layout_height="wrap_content"
                    p1:id="@+id/tableLayout1">
                    <TableRow
                        p1:id="@+id/tableRow1"
                        p1:weightSum="1">
                        <LinearLayout
                            p1:orientation="horizontal"
                            p1:minWidth="25px"
                            p1:minHeight="25px"
                            p1:id="@+id/linearLayout5"
                            p1:layout_weight=".8"
                            p1:background="@drawable/border"
                            p1:layout_width="match_parent">
                            <TextView
                                p1:textAppearance="?android:attr/textAppearanceLarge"
                                p1:layout_width="match_parent"
                                p1:layout_height="fill_parent"
                                p1:id="@+id/textFrom"
                                p1:layout_marginLeft="5dp"
                                p1:layout_marginRight="5dp"
                                p1:textColor="#000" />
                        </LinearLayout>
                        <LinearLayout
                            p1:orientation="vertical"
                            p1:minWidth="25px"
                            p1:minHeight="25px"
                            p1:id="@+id/linearLayout4"
                            p1:layout_weight=".2"
                            p1:background="@drawable/border">
                            <LinearLayout
                                p1:orientation="horizontal"
                                p1:minWidth="25px"
                                p1:minHeight="25px"
                                p1:id="@+id/linearLayout7"
                                p1:layout_width="match_parent"
                                p1:layout_height="wrap_content">
                                <TextView
                                    p1:textAppearance="?android:attr/textAppearanceSmall"
                                    p1:layout_width="match_parent"
                                    p1:layout_height="fill_parent"
                                    p1:id="@+id/textDate"
                                    p1:gravity="top"
                                    p1:textColor="#000" />
                            </LinearLayout>
                            <LinearLayout
                                p1:orientation="horizontal"
                                p1:minWidth="25px"
                                p1:minHeight="25px"
                                p1:layout_width="match_parent"
                                p1:layout_height="wrap_content"
                                p1:id="@+id/linearLayout8">
                                <TextView
                                    p1:textAppearance="?android:attr/textAppearanceSmall"
                                    p1:layout_width="match_parent"
                                    p1:layout_height="fill_parent"
                                    p1:id="@+id/textTime"
                                    p1:gravity="top"
                                    p1:textColor="#000" />
                            </LinearLayout>
                        </LinearLayout>
                    </TableRow>
                </TableLayout>
                <LinearLayout
                    p1:orientation="horizontal"
                    p1:minWidth="25px"
                    p1:minHeight="25px"
                    p1:layout_width="fill_parent"
                    p1:layout_height="wrap_content"
                    p1:id="@+id/linearLayout6"
                    p1:background="@drawable/border"
                    p1:layout_weight="1">
                    <TextView
                        p1:textAppearance="?android:attr/textAppearanceMedium"
                        p1:layout_width="match_parent"
                        p1:layout_height="fill_parent"
                        p1:id="@+id/textMessage"
                        p1:layout_marginLeft="5dp"
                        p1:layout_marginRight="5dp"
                        p1:textColor="#000" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        p1:orientation="vertical"
        p1:minWidth="25px"
        p1:minHeight="25px"
        p1:layout_width="wrap_content"
        p1:layout_height="fill_parent"
        p1:id="@+id/linearLayout12"
        p1:layout_weight=".15" />
</LinearLayout>
</LinearLayout>

边框文件是这个

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
   <stroke android:width="1dip" android:color="@android:color/transparent"/>
</shape>

无论消息的大小如何,关于如何确保布局的任何想法都保持不变?

由于

0 个答案:

没有答案