【发布时间】:2012-04-25 08:48:15
【问题描述】:
我想将布局权重分配给 LinearLayout 内 ScrollView 内的多个项目。但是,ScrollView 会忽略 LinearLayout weightSum。
我的目标是将布局划分为 2、1、1 的权重(总和为 4),但这在 ScrollView 内无法正常工作。
如何解决这个布局问题?
main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="4">
<LinearLayout android:id="@+id/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#FFFFFF" />
<LinearLayout android:id="@+id/logo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:background="#000000" />
<LinearLayout android:id="@+id/logobutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:background="#4B4B4B" />
</LinearLayout>
</ScrollView>
【问题讨论】:
-
检查这个:Android Layout Weight 我认为这是同样的问题。
-
如果我只删除滚动视图而不是工作但我的问题是如果我使用滚动视图而不是工作