簡體   English   中英

如何修復底部按鈕上的軟鍵盤重疊?

[英]How to fix soft keyboard overlaps on bottom button?

這是我的布局。 在我的清單上它有windowSoftInputMode:"adjustResize|stayVisible它不一定與我的按鈕重疊,但它有 2 秒的延遲,然后它將停止在我的按鈕上重疊。希望有人能幫助我。我應該使用 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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM