[英]RelativeLayout with MATCH_PARENT doesn't work
这就是我想要实现的目标:我在桌面上有很多表行。 每行应该有两个文本视图,产品标题和副标题相互叠加(副标题尚未实现)。 应该左对齐。 在右边,我想要一个微调器来选择数量。
文本来自数据库,当然有不同的长度。
这是我到目前为止所提出的:
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/barmenu"
android:background="#99ffff"
android:scrollbars="vertical">
<TableRow
android:layout_height="wrap_content"
android:background="#ffff99"
android:layout_width="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:background="#0000ff">
<TextView
android:id="@+id/productTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#88ffff"
android:ellipsize="end"
android:padding="2dp"
android:singleLine="true"
android:text="Product name"
android:textColor="#000000"
android:gravity="left"
android:textSize="13sp"
android:textStyle="bold" />
<Spinner
android:gravity="right"
android:layout_height="40dp"
android:layout_toRightOf="@id/productTitle"
android:width="100dp"
android:layout_width="wrap_content" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:background="#ffff99"
android:layout_width="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:background="#0000ff">
<TextView
android:id="@+id/productTitle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#88ffff"
android:ellipsize="end"
android:padding="2dp"
android:singleLine="true"
android:text="Some long long long long name"
android:textColor="#000000"
android:gravity="left"
android:textSize="13sp"
android:textStyle="bold" />
<Spinner
android:gravity="right"
android:layout_height="40dp"
android:layout_toRightOf="@id/productTitle2"
android:width="100dp"
android:layout_width="wrap_content" />
</RelativeLayout>
</TableRow>
</TableLayout>
</ScrollView>
Screendump:
第一个问题是RelativeLayout没有填写表格行的宽度。 第二个问题:纺纱厂没有正确对齐。
我错过了什么?
最好的问候艾伦
机器人:fillViewport = “真”
将此行添加到您的ScollView属性中,您就完成了:)
我会让它更简单,更轻松。 只需对所有这4个视图使用RelativeLayout
。 将两个微调器对齐并使用 - match_parent
进行textview,并将相对微调器添加到toLeftOf
。 我想你会看到你想要的东西。
将android:layout_weight="1"
到你的relativelayout
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.