滚动视图底部的Android按钮(Android Buttons at the bottom in a scrollview)

编程入门 行业动态 更新时间:2024-10-27 14:35:10
滚动视图底部的Android按钮(Android Buttons at the bottom in a scrollview)

我有一个带有RelativeLayout的ScrollView。 我将在底部有2/3按钮,但它们不会留在底部。 谁能看到我做错了什么?

<?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>

I have a ScrollView with a RelativeLayout. I'm gonna have 2 / 3 buttons at the bottom, but they wont stay at the bottom. Can anyone see where i did things wrong?

<?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>

如果你注意到我在scrollview上插入了android:fillViewport =“true”

if you check correctly the buttons are at the bottom of the relative layout. The problem is the scrollview that is not taking full screen. Check this 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>

If you notice i have inserted the android:fillViewport="true" at scrollview

更多推荐

本文发布于:2023-08-05 12:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1432711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   按钮   Android   scrollview   Buttons

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!