繁体   English   中英

滚动视图底部的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>

如果您检查正确,则按钮位于相对布局的底部。 问题是没有全屏显示的滚动视图。 检查此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”

只需尝试将相对布局的height属性更改为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” ....这会扩展布局以覆盖整个滚动视图...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM