簡體   English   中英

顯示鍵盤時布局未向上移動

[英]layout is not moving up when keyboard is shown

我的活動中有一個NestedScrollView ,其中包含大約7-8個編輯文本,並且在顯示鍵盤時需要它們向上移動。 我正在這樣做,但是沒有用

android:windowSoftInputMode="adjustPan|adjustResize"

activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_login"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:focusableInTouchMode="true"
    tools:context="com.amir_p.cafino.LoginActivity">

    <ImageView
        android:id="@+id/back_img"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop" />

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/grayTransparent" />

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:id="@+id/signup_layout"
        android:fillViewport="true"
        android:layout_height="wrap_content"
        android:visibility="gone">

        <LinearLayout
            android:id="@+id/register_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:padding="16dp">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="36dp"
                android:hint="نام و نام خانوادگی"
                android:textColorHint="@color/white">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:backgroundTint="@color/white" />
            </android.support.design.widget.TextInputLayout>

            [...]
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</RelativeLayout>

嘗試為您的滾動視圖添加android:fillViewport="true"

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:visibility="visible">

並在清單中添加:

android:windowSoftInputMode="stateVisible|adjustResize"

您可以通過編程方式關閉填充屏幕模式:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

全屏模式不會調整大小。

或者您可以使用其他主題: android:theme="@android:style/Theme.Black.NoTitleBar

暫無
暫無

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

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