scrollview не применяется для кнопок в android - PullRequest
0 голосов
/ 04 марта 2020

Привет в приведенном ниже макете xml. Я спроектировал форму со scollview. Когда я прокручиваю, кнопки не отображаются.

Я хочу отображать кнопки также, когда я прокручиваю форму. для полной формы, а также для кнопок «Сохранить» и «Отмена», но кнопки «Сохранить» и «Отмена» не отображаются.

Может ли кто-нибудь мне помочь, если я ошибся

xml:

<?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"
    android:background="@color/back_blue">

    <ScrollView
        android:id="@+id/below"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/header">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="fill_horizontal"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/account_name"
                        android:inputType="textEmailAddress"
                        android:textColorHint="#0072BA"
                        android:textSize="15sp"
                        app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" />

                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/ownership_type"
                        android_id="@+id/ownership_type"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_floatingLabelColor="#00FF00"
                        app_ms_floatingLabelText="floating label"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        app_ms_multiline="true"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/facility_type"
                        android_id="@+id/facility_type"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/email"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/email"
                        android:inputType="number" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/account_manger"
                        android_id="@+id/account_manger"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/editMobilephone"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/custom_mobile"
                        android:inputType="number" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_add"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_address"
                        android:inputType="text"
                        android:lines="5"
                        android:maxLines="5" />
                </com.google.android.material.textfield.TextInputLayout>


                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_city"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_city"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_dist"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_district"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/state"
                        android_id="@+id/state"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_floatingLabelColor="#00FF00"
                        app_ms_floatingLabelText="floating label"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        app_ms_multiline="true"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_country"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_country"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_marginTop="8dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_pin"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_pin"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_marginTop="8dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/website"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_pin"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

            </LinearLayout>


    <LinearLayout
        android:id="@+id/btnLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        android:orientation="horizontal"
        android:weightSum="2">

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/save"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:text="@string/save"
            android:textColor="@android:color/white"
            android:textSize="16sp" />

        <View
            android:layout_width="1dp"
            android:layout_height="fill_parent"
            android:background="@color/White" />

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/cancel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:text="@string/cancel"
            android:textColor="@android:color/white"
            android:textSize="16sp" />

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

Ответы [ 3 ]

0 голосов
/ 04 марта 2020

Попробуйте,

<?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"
    android:background="@color/back_blue">

    <ScrollView
        android:id="@+id/below"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btnLayout"
        android:layout_below="@+id/header">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="fill_horizontal"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/account_name"
                        android:inputType="textEmailAddress"
                        android:textColorHint="#0072BA"
                        android:textSize="15sp"
                        app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" />

                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/ownership_type"
                        android_id="@+id/ownership_type"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_floatingLabelColor="#00FF00"
                        app_ms_floatingLabelText="floating label"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        app_ms_multiline="true"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/facility_type"
                        android_id="@+id/facility_type"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/email"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/email"
                        android:inputType="number" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/account_manger"
                        android_id="@+id/account_manger"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/editMobilephone"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/custom_mobile"
                        android:inputType="number" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_add"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_address"
                        android:inputType="text"
                        android:lines="5"
                        android:maxLines="5" />
                </com.google.android.material.textfield.TextInputLayout>


                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_city"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_city"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_dist"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_district"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp">

                    <fr.ganfra.materialspinner.MaterialSpinner
                        android:id="@+id/state"
                        android_id="@+id/state"
                        android_layout_height="wrap_content"
                        android_layout_width="match_parent"
                        app_ms_arrowColor="#0000FF"
                        app_ms_arrowSize="16dp"
                        app_ms_floatingLabelColor="#00FF00"
                        app_ms_floatingLabelText="floating label"
                        app_ms_hint="hint"
                        app_ms_hintColor="#00FF00"
                        app_ms_multiline="true"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:ms_arrowColor="@color/black"
                        app:ms_hintColor="@color/black" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_country"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_country"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_marginTop="8dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/bill_pin"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_pin"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_marginTop="8dp"
                    app:passwordToggleEnabled="true"
                    app:passwordToggleTint="@color/colorAccent">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/website"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bill_pin"
                        android:inputType="text" />
                </com.google.android.material.textfield.TextInputLayout>

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

    <LinearLayout
        android:id="@+id/btnLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        android:orientation="horizontal"
        android:weightSum="2">

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/save"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:text="@string/save"
            android:textColor="@android:color/white"
            android:textSize="16sp" />

        <View
            android:layout_width="1dp"
            android:layout_height="fill_parent"
            android:background="@color/White" />

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/cancel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:text="@string/cancel"
            android:textColor="@android:color/white"
            android:textSize="16sp" />

    </LinearLayout>
</RelativeLayout>

Ожидаемое поведение для этого ответа

Expected behavior for this answer

Если вы рисуете нужную форму макета в вопрос, это будет легче понять.

0 голосов
/ 04 марта 2020

Вам нужно создать кнопку вне ScrollView.

0 голосов
/ 04 марта 2020

Попробуйте вот так

<RelativeLayout>

     <ScrollView>

          <LinearLayout>
               .......
          </LinearLayout>

     </ScrollView>

</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...