滚动视图底部的Android按钮
问题描述:
我有一个带有RelativeLayout的ScrollView。 我会在底部有2/3个按钮,但他们不会停留在底部。 任何人都可以看到我做错了什么地方?滚动视图底部的Android按钮
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/activity_bygg"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="@string/hjem"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="@string/neste"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
答
如果您正确检查按钮位于相对布局的底部。问题是没有全屏显示的滚动视图。检查此xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/activity_bygg"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="@string/hjem"/>
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:text="@string/neste"/>
</RelativeLayout>
</ScrollView>
如果你发现我已插入了android:fillViewport = “真” 的滚动型
答
只是试图改变相对布局的高度属性match_parent:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/activity_bygg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="@string/hjem"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="@string/neste"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
答
使用android:fillViewPort =“true”....这扩展了布局以覆盖整个滚动视图...
通过将RelativeLayout高度更改为match_parent来进行尝试。 – dex
scrollview是框架布局,为什么你的RelativeLaoyout应该到底?不要尝试使用(相对(滚动,按钮,按钮))? – mmprog