我多次尝试绘制如下图所示的相对布局。但没有成功。
我用颜料设计图像是为了更好地解释我的意思。 有什么建议吗?
最佳答案
试试这个(这是我在评论中首先提出的布局):
<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")。
显然,您可以使用任何其他控件来代替 TextView:按钮、ImageView 的任意组合。
关于Android:Row.xml 的相对布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22127368/