我试图让我的 ScrollView 占据屏幕的整个宽度。我在其所在行和 ScrollView 上使用了匹配父级。但是它仍然不会扩展到屏幕的整个宽度。我尝试过其他东西,例如 fill:viewport 但效果不佳。 链接到当前输出的屏幕截图/image/2EUlE.jpg 我在 ScrollView 上设置了粉红色的背景色
ScrollView 及其所在行的 XML 代码
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:background="@color/corn"
android:fillViewport="true" >
<TableLayout
android:id="@+id/completeTable"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TableLayout>
</ScrollView>
</TableRow>
插入 ScrollView 的表行代码(不认为这是问题
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/task"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/deleteItem" />
</TableRow>
最佳答案
您应该考虑为您的应用程序屏幕使用LinearLayout
/RelativeLayout
/FrameLayout
!
我认为你的问题是因为你的主TableLayout
中有很多tablerows占据了你的ScrollView
。您在 wrap_content
上设置了 TableRow
,这可能会压扁您的 ScrollView
!
关于java - Android-如何让 ScrollView 占据屏幕的整个宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24335682/