java - 如何更改windowSoftInputMode

标签 java android window-soft-input-mode

我有一个 Android 应用程序,它可以工作。在一项 Activity 中,我有一个简单的 EditText 和一个按钮。因此,当我单击 EditText 时,键盘会显示,但它位于按钮上。我不想要这个,我不知道当键盘显示时是否可以转换到组件的顶部。

这是AndroidManifest的代码:

<activity
   android:name="com.bioresult.geopointer.activity.settingActivity"
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
   android:windowSoftInputMode="stateVisible|adjustResize"
   android:configChanges="orientation|screenSize">            
</activity>

这是 Activity 的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="#4d4d4d"
    android:gravity="center_horizontal"
    android:baselineAligned="false">

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_gravity="center_vertical|center_horizontal"
        android:gravity="center_vertical|center_horizontal"
        android:layout_margin="15dp">

        <EditText
           android:id="@+id/editTextPartitaIva" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:hint="@string/nomeAzienda"
           android:lines="1"
           android:singleLine="true"/>   

        <Button 
           android:id="@+id/buttonSalva" 
           android:layout_width="match_parent"
           android:layout_height="40dp"
           android:layout_marginTop="15dp"
           android:textColor="#FFFFFF"
           android:text="@string/salva"
           android:textSize="20sp"
           android:onClick="salva"
           android:background="@drawable/salva_partitaiva_button"
           />
    </LinearLayout>



</LinearLayout>

最佳答案

https://code.google.com/p/android/issues/detail?id=5497

要避免这种情况,请删除 Activity 的 FullScreen 主题

来自FLAG_FULLSCREEN

Window flag: hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself -- the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.

关于java - 如何更改windowSoftInputMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28237539/

相关文章:

android - adjustResize 不适用于 fragment 布局内的 EditText View

具有多行和 adjustPan windowSoftInputMode 的 Android edittext

android - Android 中的软键盘隐藏了 EditText

java - 从android在线数据库中插入数据

java - 使用 AlertDialog 复制 ProgressDialog

android - expo 构建(IOS 和 android)和 Expo 发布错误

android - 图像从可绘制文件夹中消失了吗?

java - ExceptionMapper 在 Jersey 2.x 和 javax 中无法一致工作

java - 如何反序列化对象?

Java 网络服务 "HTTP status 404"- Eclipse、Apache、Tomcat