Android 如何将按钮设置在固定位置,即使相应的活动具有ScrollView

Android 如何将按钮设置在固定位置,即使相应的活动具有ScrollView,android,android-scrollview,Android,Android Scrollview,当活动具有ScrollView组件时,是否有方法使用一些不可滚动的视图 我希望我的按钮的行为与下面问题中的按钮类似,我希望它也固定在UI的底部: 这是我的布局代码: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

当活动具有ScrollView组件时,是否有方法使用一些不可滚动的视图

我希望我的按钮的行为与下面问题中的按钮类似,我希望它也固定在UI的底部:

这是我的布局代码:

<?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">
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent ">

    <FrameLayout
        android:id="@+id/map_frameview"
        android:layout_width="match_parent"
        android:layout_height="200dp">
    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="20dp">
    </LinearLayout>

</LinearLayout>
</ScrollView>


提前谢谢

您在问题中附加的链接显示了您可以如何做到这一点。您可以为此使用
RelativeLayout
。想法是,你需要告诉一个按钮停留在屏幕的底部&告诉scrollview停留在按钮的上方,以及它的可滚动内容,如:

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

    <Button
        android:id="@+id/btnMy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btnMy">

        <LinearLayout
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/btnMy"
            android:orientation="vertical">

            <FrameLayout
                android:id="@+id/map_frameview"
                android:layout_width="match_parent"
                android:layout_height="200dp">
            </FrameLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingTop="20dp">
            </LinearLayout>

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

将按钮置于滚动视图之外,并将其置于底部。