【问题标题】:How to set layout above soft keyboard如何在软键盘上方设置布局
【发布时间】:2015-11-02 09:22:53
【问题描述】:

我有下一个 xml 布局

<ScrollView
    android:id="@+id/transfer_scroller"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/blue_500"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:orientation="vertical" ></LinearLayout>
        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:orientation="vertical" ></LinearLayout>
        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <EditText
                        android:id="@+id/tv_money_type"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal|center_vertical"
                        android:textColor="@color/gray_400">
                    </EditText>
                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:background="@android:color/transparent"
                        android:text="@string/btn_transfer_select_receiver"
                        android:textColor="@color/blue_500" />

        </LinearLayout>          
</LinearLayout>

当我向下滚动并单击 editText - 打开 softKeyBoard 并调整布局大小时,我只能看到 editText 字段,并且我需要所有最后的 LinearLayout 都在键盘上方,以便用户可以在 editText 下方看到 btn。

这是我在清单中的活动:

<activity
            android:name=".acitivity.Activity"
            android:label="@string/title_activity"
            android:theme="@style/AppTheme.NoActionBar"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan|stateVisible">
        </activity>

我试图设置 android:windowSoftInputMode="adjustResize",但它似乎不适用于 scrollView...

知道如何解决这个问题吗?

【问题讨论】:

  • 你的意思是scrollView里面的主要LinearLayout?还是 ScrollView?
  • 你应该在滚动视图中设置

标签: android android-layout scrollview window-soft-input-mode


【解决方案1】:

1) 在 AndroidManifest.xml 中使用:

            android:windowSoftInputMode="adjustResize"

2) Check this one...

3) 或者你可以试试这个:

            android:windowSoftInputMode="adjustResize|stateVisible"

如果您原本需要打开键盘。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2020-05-01
    • 2018-12-01
    • 2015-11-01
    • 2016-10-14
    • 1970-01-01
    • 2016-04-20
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多