【发布时间】:2013-09-20 16:30:04
【问题描述】:
我有一个 GridLayout(我以编程方式向其中添加子项)。
结果很丑,因为 GridLayout 没有填满所有可用空间。
这是结果:
这是我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.GridLayout
android:id="@+id/gridlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
</android.support.v7.widget.GridLayout>
</HorizontalScrollView>
</ScrollView>
【问题讨论】:
-
真诚地,我从来没有在 HorizontalScrollView 中看到过 GridLayout,都在 ScrollView 中:为什么你需要所有这些滚动?
-
因为事情可能会变大,这取决于用户输入:-)
-
尝试添加
android:fillViewport="true"并将android:layout_width="match_parent"更改为android:layout_width="wrap_content"。在您的 HorizontalScrollView 中进行这些更改。
标签: android