网格布局宽度问题

时间:2013-01-10 17:32:42

标签: android user-interface grid-layout

我一直在开发一个应用程序,我也需要处理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 个答案:

答案 0 :(得分:6)

使用带有fill_horizontal的GridLayout时遇到了类似的问题。我的解决方案是设置android:layout_width="0dp",因此您可能希望在第二列中为所有视图尝试此操作。

Source

相关问题