如何修改表格以使键盘不会阻塞?

问题描述

| 我的android应用程序的第一个活动中有一个登录屏幕。当用户在填写用户名字段后选择密码字段时,虚拟屏幕键盘会弹出并阻止密码字段。用户无法查看他们正在输入的内容。我怎么解决这个问题? 以下是我的main.xml:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout style=\"@style/LoginScreen\" xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:background=\"#fff\"
>
<ListView android:id=\"@+id/listView1\" android:layout_height=\"wrap_content\" android:layout_width=\"match_parent\"></ListView>

<ImageView android:id=\"@+id/imageView1\" android:layout_height=\"wrap_content\" android:layout_width=\"wrap_content\" android:src=\"@drawable/logo\"></ImageView>
<TextView android:textColor=\"#000\" android:layout_width=\"wrap_content\" android:id=\"@+id/textView1\" android:layout_height=\"wrap_content\" android:text=\"Enter your Google Account credentials:\"></TextView>
<TextView style=\"@style/LoginLabel\" android:layout_width=\"wrap_content\" android:id=\"@+id/textView1\" android:layout_height=\"wrap_content\" android:text=\"Username:\"></TextView>
<EditText android:layout_width=\"match_parent\" android:id=\"@+id/login_username\" android:layout_height=\"wrap_content\"></EditText>
<TextView style=\"@style/LoginLabel\" android:layout_width=\"wrap_content\" android:id=\"@+id/textView2\" android:layout_height=\"wrap_content\" android:text=\"Password:\"></TextView>
<EditText android:id=\"@+id/login_password\" android:layout_height=\"wrap_content\" android:layout_width=\"match_parent\" android:password=\"true\"></EditText>
<Button style=\"@style/LoginButton\" android:id=\"@+id/login_button\" android:layout_height=\"wrap_content\" android:layout_width=\"match_parent\" android:text=\"Login\"></Button>
<LinearLayout android:id=\"@+id/linearLayout1\" android:layout_height=\"wrap_content\" android:layout_width=\"match_parent\">
</LinearLayout>
    

解决方法

        在清单中,您可以定义希望软键盘修改布局的方式,例如:
      <activity android:name=\".YourActivity\"
              android:windowSoftInputMode=\"adjustResize\"/>   
这样可以将组件的大小调整为“最适合”。您也可以使用
adjustPan
,在这种情况下,可见区域会四处移动以将焦点放在文本框上。 看到这个。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...