2011-06-10 18 views
2

我的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> 

回答

7

在你的清单,你可以定义你想怎么软键盘来修改你的布局,如:

 <activity android:name=".YourActivity" 
       android:windowSoftInputMode="adjustResize"/> 

这会调整组件的“最适合”。您也可以使用adjustPan,在这种情况下,可见区域将移动以专注于您的文本框。

请参阅this

+0

大拇指给你的人。你让我从疯狂的事情中解脱出来解决了我的问题。 – 2016-11-02 23:56:02