首页上一页 1 下一页尾页 1 条记录 1/1页
Android 布局
发表在Java图书答疑
2013-07-11
是否精华
是
否
版块置顶:
是
否
Android从入门到精通3.12示例,我布局按钮时未按书上所说的LinearLayout布局,而是仍和上面一致采用TableRow,重置按钮属性设置android:layout_width="wrap_content",即自适应,为什么它的显示那么宽。
布局代码:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="会员昵称:"
android:textSize="20px"/>
<EditText android:id="@+id/nickname"
android:layout_width="wrap_content"
android:width="300px"
android:layout_height="wrap_content"
android:hint="请输入会员昵称"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入密码:"
android:textSize="20px"/>
<EditText android:id="@+id/psw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textPassword"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:"
android:textSize="20px"/>
<EditText android:id="@+id/pswa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textPassword"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-mail:"
android:textSize="20px"/>
<EditText android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textEmailAddress"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/logIn"
android:text="注册"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="重置"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
因不能贴图,把代码附上,您能亲自跑一下这个代码。会发现重置按钮特别宽,求解?
布局代码:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="会员昵称:"
android:textSize="20px"/>
<EditText android:id="@+id/nickname"
android:layout_width="wrap_content"
android:width="300px"
android:layout_height="wrap_content"
android:hint="请输入会员昵称"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入密码:"
android:textSize="20px"/>
<EditText android:id="@+id/psw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textPassword"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:"
android:textSize="20px"/>
<EditText android:id="@+id/pswa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textPassword"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-mail:"
android:textSize="20px"/>
<EditText android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="300px"
android:inputType="textEmailAddress"/>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/logIn"
android:text="注册"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="重置"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
因不能贴图,把代码附上,您能亲自跑一下这个代码。会发现重置按钮特别宽,求解?