Android 如何制作按钮罐';不要卷轴

Android 如何制作按钮罐';不要卷轴,android,android-layout,android-scrollview,Android,Android Layout,Android Scrollview,我想使我的按钮不能在这里滚动。所以,当我向上或向下滚动按钮时,按钮保持在按钮上。我试图使滚动视图在按钮之外,但按钮没有出现。我也试着在scrollview中创建按钮,但是按钮变得很难使用。我想让钮扣保持在钮扣上并且可以松开 这是我的密码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"

我想使我的按钮不能在这里滚动。所以,当我向上或向下滚动按钮时,按钮保持在按钮上。我试图使滚动视图在按钮之外,但按钮没有出现。我也试着在scrollview中创建按钮,但是按钮变得很难使用。我想让钮扣保持在钮扣上并且可以松开

这是我的密码

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f1f1f1"
    android:orientation="vertical"
    tools:context=".Activity.TambahLaporActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:foreground="?android:attr/selectableItemBackground">

        <ImageView
            android:id="@+id/tambah"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/add" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:text="Lokasi dan Jenis"
                android:textColor="@android:color/black"
                android:textSize="20dp" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@color/colorPrimary"/>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Gedung : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/gedung"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="gedung"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Ruangan : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/ruang"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="ruang"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Pada : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/tanggal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="tanggal"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=" yang lalu"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Aset : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/aset"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="aset"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:text="Keterangan"
                android:textColor="@android:color/black"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/keterangan"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:text="ket"
                android:textColor="@android:color/black"
                android:textSize="15dp" />
        </LinearLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:text="Lokasi dan Jenis"
                android:textColor="@android:color/black"
                android:textSize="20dp" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@color/colorPrimary"/>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Gedung : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/gedung"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="gedung"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Ruangan : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/ruang"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="ruang"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Pada : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/tanggal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="tanggal"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=" yang lalu"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="Aset : "
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

                <TextView
                    android:id="@+id/aset"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="aset"
                    android:textColor="@android:color/black"
                    android:textSize="15dp" />

            </LinearLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:text="Keterangan"
                android:textColor="@android:color/black"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/keterangan"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:text="ket"
                android:textColor="@android:color/black"
                android:textSize="15dp" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
        </LinearLayout>
    </ScrollView>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:background="@color/colorPrimary"
            android:text="Cancel"
            android:textColor="@android:color/white" />
    </RelativeLayout>

</LinearLayout>

当我向上或向下滚动布局时,如何使按钮存在而不滚动?
谢谢你

试试这段代码它很好用,把你想要的东西放进你的
线性布局中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.TambahLaporActivity">

    <Button
        android:id="@+id/btn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@color/colorPrimary"
        android:text="Cancel"
        android:textColor="@android:color/white" />

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">



        </LinearLayout>

    </ScrollView>

</RelativeLayout>

您需要将滚动视图包装到按钮的相对位置

<RelativeLayout>
    <ScrollView>
        .......
    <Scrollview/>
    <Button/>
<RelativeLayout/>

.......