问题描述
main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" ><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:id="@+id/passwordlab" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/passwordlab" /> <EditText android:id="@+id/password" android:layout_width="150px" android:layout_height="50px" android:layout_toRightOf="@id/passwordlab" android:layout_marginRight="50px" android:layout_alignTop="@id/password" /></RelativeLayout><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="wrap_content" ><TextViewandroid:id="@+id/usernamelab"android:text="@string/usernamelab"android:layout_width="wrap_content"android:layout_height="wrap_content" /><EditTextandroid:id="@+id/username"android:layout_width="150px"android:layout_height="30px"android:layout_toRightOf="@id/usernamelab"android:layout_alignTop="@id/usernamelab"android:layout_marginRight="20px"/></RelativeLayout><Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/set" android:id="@+id/setbutton"/></LinearLayout>string.xml<?xml version="1.0" encoding="utf-8"?><resources> <string name="app_name">SharedPreference</string> <string name="usernamelab">用戶名</string> <string name="passwordlab">密碼</string> <string name="set">保存按鈕</string></resources>显示效果如下图:
解决方案
<TextView android:id="@+id/passwordlab" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/passwordlab" /> 找到这个地方,你的height设置成了fill_parent能不只显示上面的才奇怪了,(*^__^*) 嘻嘻……