Подтвердить что ты не робот

Вид родительского дна скрывается с макетом макета на открывающей клавиатуре

Я работаю над компоновкой, где я выровнял один cardview в центре экрана и обратился к нам button в нижней части экрана. Этот макет выглядит нормально, когда клавиатура закрыта.

Он выглядит следующим образом: - введите описание изображения здесь

layout.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

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

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

                <ImageView
                    android:id="@+id/login_image"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:background="@drawable/login_background" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:background="@color/grey_background" />

            </LinearLayout>


            <android.support.v7.widget.CardView
                android:id="@+id/media_card_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_marginLeft="24dp"
                android:layout_marginRight="24dp"
                card_view:cardBackgroundColor="@color/white"
                card_view:cardElevation="4dp"
                card_view:cardCornerRadius="5dp"
                >

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

                    >

                    <ImageView
                        android:id="@+id/logoImageView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="@color/grey_background"
                        android:padding="15dp"
                        android:src="@drawable/logo_login"
                        />

                    <EditText
                        android:id="@+id/usertext"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_below="@id/logoImageView"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:layout_marginTop="20dp"
                        android:background="@drawable/edittext_background"
                        android:hint="User ID"
                        android:maxLength="50"
                        android:padding="10dp"
                        android:singleLine="true"
                        android:textColorHint="@color/hint_text_color"
                        android:textSize="16sp" />


                    <FrameLayout
                        android:id="@+id/passwordLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/usertext"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <EditText
                            android:id="@+id/passtext"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginLeft="20dp"
                            android:layout_marginRight="20dp"
                            android:background="@drawable/edittext_background"
                            android:fontFamily="sans-serif"
                            android:hint="@string/password"
                            android:inputType="textPassword"
                            android:maxLength="50"
                            android:padding="10dp"
                            android:singleLine="true"
                            android:textColorHint="@color/hint_text_color"
                            android:textSize="16sp" />

                        <ImageView
                            android:id="@+id/passwordeye"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="right|center_vertical"
                            android:padding="8dp"
                            android:layout_marginRight="25dp"
                            android:src="@drawable/eye_close" />

                    </FrameLayout>

                    <LinearLayout
                        android:id="@+id/termsLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/passwordLayout"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="20dp"
                        android:layout_marginTop="15dp"
                        android:gravity="center"
                        android:orientation="horizontal">


                        <ImageView
                            android:id="@+id/check_box"
                            android:layout_width="wrap_content"

                            android:layout_height="wrap_content"
                            android:padding="5dp"
                            android:src="@drawable/checkbox_checked" />

                        <TextView
                            android:id="@+id/terms_and_cond"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:textColor="@color/black"
                            android:textColorLink="#80000000"
                            android:textSize="13sp" />
                    </LinearLayout>

                    <View
                        android:id="@+id/lineView"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/termsLayout"
                        android:layout_marginTop="15dp"
                        android:background="@color/grey_background" />

                    <LinearLayout
                        android:id="@+id/newuser_login_layout"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:background="@color/dark_grey"
                        android:layout_below="@id/lineView"
                        android:orientation="horizontal">


                        <TextView
                            android:id="@+id/newUserButton"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/translucent_round_button"
                            android:gravity="center"
                            android:text="New User ?"
                            android:textColor="@color/grey_text_color"
                            android:textSize="17sp" />

                        <TextView
                            android:id="@+id/loginbutton"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/bottom_round_button"
                            android:gravity="center"
                            android:text="Login"
                            android:textColor="@color/white"
                            android:textSize="17sp" />

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_gravity="center"
                android:gravity="center"
                android:orientation="vertical">


                <TextView
                    android:id="@+id/contactus_button"
                    android:layout_width="wrap_content"
                    android:layout_height="35dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="15dp"
                    android:background="@drawable/contact_us_selector"
                    android:drawableLeft="@drawable/contact_us_green"
                    android:drawablePadding="5dp"
                    android:gravity="center"
                    android:padding="8dp"
                    android:text="Contact Us"
                    android:textColor="@color/black" />

                <TextView
                    android:id="@+id/textviewone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"
                    android:gravity="center"
                    android:textColor="@color/black"
                    android:textColorLink="#80000000"
                    android:textSize="13sp" />

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

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/snackbarCoordinatorLayout"
        android:layout_width="match_parent"

        android:layout_height="match_parent"
        >

    </android.support.design.widget.CoordinatorLayout>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/android:progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="gone" />
</FrameLayout>

Вопрос: -

Когда откроется клавиатура, свяжитесь с нами button, а текст, расположенный внизу экрана, будет скрыт за макетом центра. Я хочу, чтобы он не скрывался, при открытии клавиатуры экран должен прокручиваться и связываться с нами button должен быть внизу.

При открытии клавиатуры это выглядит так: -

введите описание изображения здесь

4b9b3361

Ответ 1

в вашем scrollview add android: isScrollContainer = "false"

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="false">

 </ScrollView>

Ответ 2

Добавлена ​​только одна строка...

Добавьте android:windowSoftInputMode="stateHidden|adjustPan" в требуемую активность вашего файла манифеста.

Ответ 3

Проблема заключается в том, что ваш CardView - android:layout_centerInParent="true", а ваш LinearLayout содержащий материал "Связаться с нами" - android:layout_alignParentBottom="true".

Я бы переосмыслил ваш макет, он немного грязный, но, возможно, вы можете заменить android:layout_alignParentBottom="true" на LinearLayout на android:layout_below="@+id/media_card_view".

Ответ 5

Здесь мой макет:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

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

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

                <ImageView
                    android:id="@+id/login_image"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:background="@android:color/holo_blue_bright"/>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:background="@android:color/darker_gray"/>

            </LinearLayout>


            <android.support.v7.widget.CardView
                android:id="@+id/media_card_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_marginLeft="24dp"
                android:layout_marginRight="24dp"
                card_view:cardBackgroundColor="@android:color/white"
                card_view:cardCornerRadius="5dp"
                card_view:cardElevation="4dp"
                >

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

                    >

                    <ImageView
                        android:id="@+id/logoImageView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="@android:color/darker_gray"
                        android:padding="15dp"
                        />

                    <EditText
                        android:id="@+id/usertext"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_below="@id/logoImageView"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:layout_marginTop="20dp"
                        android:background="@android:drawable/editbox_background"
                        android:hint="User ID"
                        android:maxLength="50"
                        android:padding="10dp"
                        android:singleLine="true"
                        android:textColorHint="@color/colorPrimaryDark"
                        android:textSize="16sp"/>


                    <FrameLayout
                        android:id="@+id/passwordLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/usertext"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <EditText
                            android:id="@+id/passtext"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginLeft="20dp"
                            android:layout_marginRight="20dp"
                            android:background="@android:drawable/editbox_background"
                            android:fontFamily="sans-serif"
                            android:hint="Password"
                            android:inputType="textPassword"
                            android:maxLength="50"
                            android:padding="10dp"
                            android:singleLine="true"
                            android:textColorHint="@color/colorPrimaryDark"
                            android:textSize="16sp"/>

                        <ImageView
                            android:id="@+id/passwordeye"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="right|center_vertical"
                            android:layout_marginRight="25dp"
                            android:padding="8dp"
                            android:src="@android:drawable/ic_menu_edit"/>

                    </FrameLayout>

                    <LinearLayout
                        android:id="@+id/termsLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/passwordLayout"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="20dp"
                        android:layout_marginTop="15dp"
                        android:gravity="center"
                        android:orientation="horizontal">


                        <ImageView
                            android:id="@+id/check_box"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:padding="5dp"
                            android:src="@android:drawable/checkbox_on_background"/>

                        <TextView
                            android:id="@+id/terms_and_cond"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:textColor="@android:color/black"
                            android:textColorLink="#80000000"
                            android:textSize="13sp"/>
                    </LinearLayout>

                    <View
                        android:id="@+id/lineView"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/termsLayout"
                        android:layout_marginTop="15dp"
                        android:background="@android:color/darker_gray"/>

                    <LinearLayout
                        android:id="@+id/newuser_login_layout"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_below="@id/lineView"
                        android:background="@android:color/darker_gray"
                        android:orientation="horizontal">


                        <TextView
                            android:id="@+id/newUserButton"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:text="New User ?"
                            android:textColorHint="@android:color/darker_gray"
                            android:textSize="17sp"/>

                        <TextView
                            android:id="@+id/loginbutton"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:text="Login"
                            android:textColor="@android:color/white"
                            android:textSize="17sp"/>

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/media_card_view"
                android:orientation="vertical"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:gravity="center_horizontal"
                android:layout_below="@+id/media_card_view">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="35dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="15dp"
                    android:drawableLeft="@android:drawable/sym_contact_card"
                    android:drawablePadding="5dp"
                    android:padding="8dp"
                    android:text="Contact Us"
                    android:textColor="@android:color/black"
                    android:layout_gravity="center"/>


                <TextView
                    android:id="@+id/textviewone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"
                    android:gravity="center_horizontal"
                    android:text="Copyright by piotrek1543 @2016"
                    android:textColor="@android:color/black"
                    android:textColorLink="#80000000"
                    android:textSize="13sp"/>
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>


    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/android:progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="gone"/>

</FrameLayout>

Вот как это выглядит перед открытием клавиатуры

6sM8x.png

и после:

ZvNaV.png

Прежде всего, откройте AndroidManifest и в разделе LoginActivity введите следующую строку:

     android:windowSoftInputMode="stateVisible|adjustResize">

После этого ваш манифест Activity должен выглядеть так:

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateVisible|adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

Затем измените свой LinearLayout с помощью полей textoneview и textview1 следующим образом:

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/media_card_view"
            android:orientation="vertical"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:gravity="center_horizontal"
            android:layout_below="@+id/media_card_view">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="35dp"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="15dp"
                android:drawableLeft="@android:drawable/sym_contact_card"
                android:drawablePadding="5dp"
                android:padding="8dp"
                android:text="Contact Us"
                android:textColor="@android:color/black"
                android:layout_gravity="center"/>


            <TextView
                android:id="@+id/textviewone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:gravity="center_horizontal"
                android:text="Copyright by piotrek1543 @2016"
                android:textColor="@android:color/black"
                android:textColorLink="#80000000"
                android:textSize="13sp"/>
        </LinearLayout>

Надеюсь, что это поможет

РЕДАКТИРОВАТЬ. Если вы хотите оставить BottomSheetStyle вашего линейногоLayout, вы можете использовать этот код:

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignBottom="@id/media_card_view"
            android:orientation="vertical"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:gravity="center_horizontal|bottom"
            app:layout_behavior="@string/bottom_sheet_behavior"
            >

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="35dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="45dp"
                android:layout_marginBottom="15dp"
                android:drawableLeft="@android:drawable/sym_contact_card"
                android:drawablePadding="5dp"
                android:padding="8dp"
                android:text="Contact Us"
                android:textColor="@android:color/black"
                android:gravity="center"
                android:layout_gravity="center"/>


            <TextView
                android:id="@+id/textviewone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:gravity="center_horizontal"
                android:text="Copyright by piotrek1543 @2016"
                android:textColor="@android:color/black"
                android:textColorLink="#80000000"
                android:textSize="13sp"/>
        </LinearLayout>

чтобы он выглядел так:

xn98B.png

но после того, как вы откроете клавиатуру, вы увидите

yqgsr.png

Ваш "Связаться с нами" будет скрыт за CardView. Если вы хотите, чтобы оба TextView думали об уменьшении размера media_card_view. Для меня это слишком большое, чтобы видеть оба вида видимыми.

Ответ 6

Вы просто добавляете несколько строк в свой код

Файл манифеста:

 <activity
        android:name=".activities.LoginActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden|adjustResize" />

Если вы установили фон, тогда проблема с прокруткой затем установите программный фон, как показано ниже

   getWindow().setBackgroundDrawableResource(R.drawable.app_bg) ;

Ответ 7

Пожалуйста, проверьте это. Я не уверен, что это поможет или нет.

ScrollView view = (ScrollView)findViewById(R.id.scrollView);
view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        v.requestFocusFromTouch();
        return false;
    }
});

Ответ 8

Я бы поставил android:layout_below="@id/media_card_view" в LinearLayout, который содержит кнопку "Контакты" и удаляет из нее android:layout_alignParentBottom="true".

Также вы можете установить android:layout_height="wrap_content" в основной RelativeLayout и, возможно, удалить CoordinatorLayout, если он не используется в этом макете.

Надеюсь, что это поможет;)