Android 如果使用滚动视图,如何在页面底部留出空间
这里我使用了滚动视图,我想在页面底部留出一个空间,这样只有条款和条件可以滚动,复选框和按钮不能滚动。它应该在页面底部。你能帮我处理xml吗。我附上了一个图像,我想这样的设计,在底部的按钮不动Android 如果使用滚动视图,如何在页面底部留出空间,android,android-studio,user-interface,graphics,android-xml,Android,Android Studio,User Interface,Graphics,Android Xml,这里我使用了滚动视图,我想在页面底部留出一个空间,这样只有条款和条件可以滚动,复选框和按钮不能滚动。它应该在页面底部。你能帮我处理xml吗。我附上了一个图像,我想这样的设计,在底部的按钮不动 如果我正确理解了你的问题,你可以这样说: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.co
如果我正确理解了你的问题,你可以这样说:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/bottom_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:gravity="center"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="I agree with the Terms and Conditions"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:gravity="center"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="I agree with the Privacy Policy"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:paddingTop="16dp"
android:paddingBottom="32dp"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:layout_marginRight="32dp"
android:text="decline"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:text="accept"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:paddingTop="16dp"
android:paddingBottom="8dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/your_image"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="Terms of service"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Update date"/>
</LinearLayout>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_parent"
android:layout_below="@id/top_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- ADD YOUR TEXTVIEWS HERE -->
</LinearLayout>
</ScrollView>
使用上面的android:layout_和下面的android:layout_定义您的滚动视图位置尝试在屏幕底部甚至滚动视图的下方添加按钮 在scrollView或父LinearLayout中添加此项
<ScrollView>
android:layout_above="@+id/bottom_panel"
android:layout_Upper=“@+id/底部_面板”
将其添加到xml的最底部
</ScrollView>
</LinearLayout>
--------------- ADD HERE - Below Scroll View -------
<LinearLayout
android:id="@+id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom" OR android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Decline"/>
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Accept"/>
</LinearLayout>
</RelativeLayout>
---------------在此处添加-滚动视图下方-------
让我知道它是否工作正常当“android:layout_over=“@+id/bottom_panel”被放置在父线性布局中时,它工作正常。。谢谢你很高兴知道它对你有用,你可以把最适合你的答案标记为正确,也可以加一票:)
</ScrollView>
</LinearLayout>
--------------- ADD HERE - Below Scroll View -------
<LinearLayout
android:id="@+id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom" OR android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Decline"/>
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Accept"/>
</LinearLayout>
</RelativeLayout>