网格布局宽度问题

4

我一直在开发一款应用程序,同时也需要处理UI方面的事情。

这是我的XML:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
  <GridLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:columnCount="2" >
    <ImageView />
    <TextView />
    .
    .
  </GridLayout>
</ScrollView>

现在的问题是右侧列的宽度超出了设备的宽度。例如,移动设备的名称具有属性android:layout_gravity设置为中心。但正如您在下面的屏幕截图中所看到的那样,它并没有按预期工作:

Device Screenshot

我应该使用什么来保持宽度在限制范围内,因为文本是动态的。
1个回答

6

我在使用fill_horizontal的GridLayout时遇到了类似的问题。对于我来说,解决方案是将所有第二列视图的android:layout_width="0dp"设置为此值可能适用于您,请尝试。

来源


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接