简体   繁体   中英

android scrollview not working with cardView and with noActionBar theme

Below xml contains a ScrollView and a Cardview but scrolling is not working for the ScrollView. I have added below line in manifest for below layout:

<activity android:windowSoftInputMode="adjustPan"
        android:name=".activities.RegisterActivity" />

Can anyone help me to fix this issue?

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:fillViewport="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
          <RelativeLayout
            android:id="@+id/relative"
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_400dp"
            android:layout_margin="@dimen/margin_10dp">
 <android.support.v7.widget.CardView
                android:id="@+id/cardview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="visible"
                app:cardBackgroundColor="@color/white"
                app:cardCornerRadius="@dimen/margin_5dp"
                app:cardElevation="@dimen/margin_20dp"
                app:cardPreventCornerOverlap="true"
                app:cardUseCompatPadding="true">


                <LinearLayout
                    android:id="@+id/linearLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="@dimen/margin_10dp"
                    android:orientation="vertical">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginTop="@dimen/margin_10dp"
                        android:src="@drawable/user_default" />

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_10dp"
                        android:textColorHint="@color/blue">


              <android.support.design.widget.TextInputEditText
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_50dp"
                            android:hint="@string/Email"
                            android:inputType="textEmailAddress"
                            android:textColor="@color/blue"
                            android:textColorHint="@color/blue"
                            android:theme="@style/MyEditTextTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"

                        android:textColorHint="@color/blue">


              <android.support.design.widget.TextInputEditText
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_50dp"
                            android:hint="@string/Name"
                            android:inputType="text"
                            android:textColor="@color/blue"
                            android:textColorHint="@color/blue"
                            android:theme="@style/MyEditTextTheme" />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/Password"
                        android:textColorHint="@color/blue"
                        app:passwordToggleEnabled="true"
                        app:passwordToggleTint="@color/blue">


              <android.support.design.widget.TextInputEditText
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_50dp"
                            android:hint="@string/Password"
                            android:inputType="textPassword"
                            android:textColor="@color/blue"
                            android:textColorHint="@color/blue"
                            android:theme="@style/MyEditTextTheme" />
                    </android.support.design.widget.TextInputLayout>


                </LinearLayout>


            </android.support.v7.widget.CardView>

        </RelativeLayout>

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_signup"
            android:layout_width="@dimen/margin_120dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/relative"
            android:layout_gravity="bottom|center"
            android:layout_marginRight="@dimen/margin_60dp"
            android:layout_marginTop="@dimen/margin_m65dp"
            android:background="@drawable/rounded_textview"
            android:gravity="center"
            android:padding="@dimen/margin_10dp"
            android:text="@string/Sign_up"
            android:textColor="@color/white"
            android:textSize="18sp"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/relative"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="@dimen/margin_10dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="@dimen/margin_10dp"
                android:text="@string/already_have_an_account"
                android:textSize="16sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:padding="@dimen/margin_5dp"
                android:text="@string/Login"
                android:textColor="@color/blue"
                android:textSize="18sp"
                android:textStyle="bold" />

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

使用android.support.v4.widget.NestedScrollView而不是ScrollView

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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