ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Android에서 소프트 키보드 위로 전체 레이아웃을 이동하는 방법은 무엇입니까?
    카테고리 없음 2020. 8. 9. 04:12

    질문

    나는 내 소프트 키보드가 열릴 때마다 내 전체 레이아웃이 Android의 해당 키보드 위에 올 때와 같은 기능을 구현하고 싶습니다. 나는 이미 그것을 구글링했고 그것과 관련된 적절한 답변을 찾고 있습니다. 하지만 내 기대대로 작동하지 않습니다.

    내 매니페스트에 android : windowSoftInputMode = "adjustResize"를 추가했습니다. 그러나 키보드 위의 제한된 레이아웃 만 수행합니다. 전체 레이아웃이 키보드 위에 있기를 바랍니다.

    아래는 더 나은 표현을 위한 이미지입니다 ...

    이미지에서 볼 수 있듯이 내 키보드가 레이아웃 위에 있습니다. 등록 button이 소프트 키보드 위에 올 때까지 전체 레이아웃을 의미합니다.

    이미지에서 볼 수 있듯이 제 키보드가 레이아웃 위에 있습니다. 등록 button이 소프트 키보드 위에 올 때까지 전체 레이아웃이 의미하기를 바랍니다.

    아래는 내 XML 코드입니다.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:orientation="vertical">
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Welcome,"
                android:textAlignment="center"
               />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Register to Get Your Grocery Store Online"
                android:textAlignment="center"
                />
    
        </LinearLayout>
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:orientation="vertical">
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/storeName"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
               >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Store Name"
                    />
            </com.google.android.material.textfield.TextInputLayout>
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/storeLocationPinCode"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
                >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Store Location PinCode"
                     />
            </com.google.android.material.textfield.TextInputLayout>
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/storeCity"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
               >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Store City"
                   />
    
            </com.google.android.material.textfield.TextInputLayout>
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/storeState"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
                >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Store State"
                   />
    
            </com.google.android.material.textfield.TextInputLayout>
    
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/storeAddress"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
                >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Store Address"
                    />
            </com.google.android.material.textfield.TextInputLayout>
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/minimumAmount"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
                >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    />
            </com.google.android.material.textfield.TextInputLayout>
    
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/deliveryCharges"
                style="@style/TextInputLayoutStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewLabel"
    
                >
    
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Delivery Charges"
                    />
            </com.google.android.material.textfield.TextInputLayout>
    
            <Button
                android:id="@+id/registerMerchant"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Register"
                android:layout_marginTop="65dp"
                android:layout_marginBottom="65dp"
               />
    
    
        </LinearLayout>
        </ScrollView>
    </LinearLayout>

     

    답변1

    귀하의 경우에는 adjustPan adjustResize보다 낫다고 생각하며 모든 레이아웃을 밀어올릴 것입니다.

    adjustResize는 레이아웃 매개 변수에 따라 달라지며, ConstraintLayout을 사용하는 경우 상위 항목의 하단에서 하단까지의 보기 전용 제약 조건이 푸시됩니다.

    <activity android:windowSoftInputMode="adjustPan"/>



    답변2

    추가 시도

    <activity android:windowSoftInputMode="adjustResize"/>

    매니페스트 파일의 Activity에 해보십시오.



     

     

     

     

    출처 : https://stackoverflow.com/questions/62459596/how-to-move-whole-layout-above-the-soft-keyboard-in-android

    댓글

Designed by Tistory.