繁体   English   中英

Android:Row.xml的相对布局

[英]Android: Relative layout for Row.xml

我多次尝试绘制相对的布局,如下图所示。 但没有成功。 在此处输入图片说明

我用油漆设计图像以更好地解释我的意思。 有什么建议么?

试试这个(这是我在评论中首先提出的布局):

<LinearLayout
    xmlns
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        >
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
        />
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40"
        />
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
        />
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
        />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        >
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
        />
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
        />
    </LinearLayout>
</LinearLayout>

为了使其更有用(即:动态分配内容),请为这些TextView提供一些ID( android:id =“ @ + id / txtSomething” )。

很显然,您可以使用任何其他控件来代替TextViews:按钮,ImageViews的任意组合。

尝试以下想法:

根-具有2个子元素的线性布局(垂直)

第一个孩子-线性布局(水平),其权重根据您的UI第二个孩子-线性布局(水平),其权重为2个孩子。

您也可以使用TableLayout ...但是它很复杂。具有2行的表布局,其中第一行有4个子项,第二行有2个子项...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM