简体   繁体   中英

How to fix soft keyboard overlaps on bottom button?

This is my layout. On my manifest it has windowSoftInputMode:"adjustResize|stayVisible It is not necessarily overlaps on my button but it has a delay like 2seconds then it will stop overlapping on my button. Hoping anyone could help me. Should i use RelativeLayout?

<?xml version="1.0" encoding="utf-8"?>
<ScrollView

        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="vertical"
        android:id="@+id/my_scroll_view"
        app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".login.WelcomeScreenActivity">


        <VideoView
                android:id="@+id/video_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center" />

            <ImageView
                    android:id="@+id/imageView27"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/half_black_view" />

        <LinearLayout
                android:id="@+id/linearLayout13"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/login_nxt_btn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent">

            <androidx.viewpager.widget.ViewPager
                    android:id="@+id/welcome_screen_viewPager"
                    android:layout_width="match_parent"
                    android:layout_height="130dp"></androidx.viewpager.widget.ViewPager>

            <com.google.android.material.tabs.TabLayout
                    android:id="@+id/welcome_screen_indicator"
                    android:layout_width="match_parent"
                    android:layout_height="20dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginRight="8dp"
                    app:tabBackground="@drawable/tab_selector"
                    app:tabGravity="center"
                    app:tabIndicatorHeight="0dp"></com.google.android.material.tabs.TabLayout>

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginLeft="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginRight="16dp"
                    android:background="@drawable/blur_bg"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                <com.hbb20.CountryCodePicker
                        android:id="@+id/ccp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginLeft="16dp"
                        app:ccpDialog_keyboardAutoPopup="false"
                        app:ccp_arrowColor="@color/white"
                        app:ccp_autoDetectCountry="true"
                        app:ccp_contentColor="@color/white"
                        app:ccp_countryPreference="in,us,nz,gb"
                        app:ccp_defaultLanguage="ENGLISH"
                        app:ccp_hintExampleNumber="true"
                        app:ccp_showFlag="false"
                        app:ccp_showNameCode="false"
                        app:ccp_textSize="13sp" />

                <View
                        android:id="@+id/sepratorView"
                        android:layout_width="1dp"
                        android:layout_height="match_parent"
                        android:layout_marginTop="4dp"
                        android:layout_marginBottom="4dp"
                        android:background="@color/app_seperator_color" />

                <EditText
                        android:id="@+id/user_number_edittext"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginLeft="16dp"
                        android:background="@android:color/transparent"
                        android:fontFamily="@font/montserrat"
                        android:hint="@string/enter_your_phone_number"
                        android:inputType="phone"
                        android:maxLength="11"
                        android:singleLine="true"
                        android:textColor="@android:color/white"
                        android:textColorHint="@color/white"
                        android:textSize="14sp" />

            </LinearLayout>

            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginBottom="20dp"
                    android:fontFamily="@font/montserrat_light"
                    android:text="@string/enter_number_recevie_otp"
                    android:textAlignment="center"
                    android:textColor="@color/white"
                    android:textSize="13sp" />



        </LinearLayout>
        <Button
            android:id="@+id/login_nxt_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/rectangle_app_btn"
            android:fontFamily="@font/montserrat_medium"
            android:text="@string/next"
            android:textAllCaps="false"
            android:textColor="@color/white"
            android:textSize="18sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

OnCreate方法中试试这个。

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

在您的活动标签的清单中尝试这一行

  android:windowSoftInputMode="adjustResize"

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