【问题标题】:How to move the layout above of soft keyboard when it is shown显示时如何移动软键盘上方的布局
【发布时间】:2015-11-01 13:09:00
【问题描述】:

我的活动有一个简单的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/editTextName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/buttonCancel"
        android:layout_alignParentTop="true" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="cancel" />


</RelativeLayout>

当我触摸EditText 时出现软键盘,但我的按钮隐藏在键盘之外!

但我希望Button 向上移动(上方)键盘。

我将这行代码添加到AndroidManifest,但没有任何改变。

<activity
    android:name=".Activity"
    android:windowSoftInputMode="adjustPan|adjustResize">
</activity>

【问题讨论】:

    标签: android keyboard android-softkeyboard soft-keyboard


    【解决方案1】:

    根据official documentation adjustPan 和adjustResize 有相反的行为,因此我认为它们不应该一起使用。试试 android:windowSoftInputMode="adjustResize" ,为我工作。

    【讨论】:

      猜你喜欢
      • 2010-12-30
      • 2012-02-25
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多