[英]Scrollview in Relative layout
I have a huge list of items which I put into linear layout and then I put that into scrollview to make it scrollable. 我有大量的项目列表,将它们放入线性布局,然后将其放入scrollview以使其可滚动。
Then I wrap it all into relative view because I want to have add button at the bottom. 然后,将它们全部包装到相对视图中,因为我想在底部添加按钮。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
A LOT OF CONTENT
</LinearLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/add"
android:text="@string/add"
android:paddingTop="23dp"/>
</RelativeLayout>
Due to add button at the bottom whenever I scroll to the very bottom of the list, the add button blocks the bottom most part of the scrollview. 由于每当我滚动到列表的最底部时,添加按钮就会位于底部,因此添加按钮会阻塞滚动视图的最底部。 How would I have scrollview fit only the part of screen that add button does not take up?
我如何让scrollview只适合添加按钮不占用的屏幕部分?
Set rule android:layout_above="@+id/add"
to ScrollView
. 将规则
android:layout_above="@+id/add"
为ScrollView
。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_above="@+id/add"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
A LOT OF CONTENT
</LinearLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/add"
android:text="@string/add"
android:paddingTop="23dp"/>
</RelativeLayout>
将此添加到滚动视图:
android:layout_above="@+id/add"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.