<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:background="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linear1"
android:background="#FF0000"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:background="#00FF00"
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="200dip"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:background="#0000FF"
android:id="@+id/linear3"
android:layout_width="match_parent"
android:layout_height="100dip"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
这是我的布局,我希望看到一个红色的背景(因为linear1的背景是红色的,并且具有填充父级的属性),另外两个布局在带有绿色和蓝色的linear1上
但我实际看到的是来自滚动视图的黑色背景,来自linear2和linear3的绿色和蓝色背景,但没有来自linear1的红色背景
即线性行为类似于android:layout_height="wrap_content“设置为android:layout_height="match_parent”
有什么想法吗?
发布于 2013-02-13 01:15:02
您需要设置fillViewport:
<ScrollView
android:id="@+id/scrollView1"
android:background="#000000"
android:layout_width="match_parent"
android:fillViewport="true" <!-- here -->
android:layout_height="match_parent" >
...
</ScrollView>
https://stackoverflow.com/questions/14837983
复制相似问题