android各种布局实现登录

linearlayout布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/system_text"
/>

<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"/>
</LinearLayout>
</LinearLayout>
_____________________________________________________________
relativelayout布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/system_text"
android:id="@+id/top_test"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:layout_below="@id/top_test"
android:id="@+id/username_test"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/username_test"
android:layout_below="@id/top_test"
android:id="@+id/usercontent_test"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:layout_below="@id/usercontent_test"
android:layout_alignParentLeft="true"
android:id="@+id/password_test"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/usercontent_test"
android:layout_toRightOf="@id/password_test"
android:layout_marginLeft="13dp"
android:id="@+id/passcontent_test"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"
android:layout_below="@id/passcontent_test"
android:layout_alignParentLeft="true"
android:layout_marginLeft="60dp"
android:id="@+id/login_test"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/login_test"
android:layout_alignBottom="@+id/login_test"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:text="@string/cancel" />

</RelativeLayout>
______________________________________________________________
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:stretchColumns="0,1"
>
<TableRow >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/system_text"
android:layout_column="0"
/>

</TableRow>

<TableRow >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:layout_column="0"
android:layout_gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1" />
</TableRow>
<TableRow >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:layout_column="0"
android:layout_gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"/>

</TableRow>
<TableRow >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_column="1"/>

</TableRow>
</TableLayout>
_____________________________________________________________
linearlayout+tablelayout布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/system_text" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="0,1">
<TableRow >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:layout_gravity="center"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:layout_gravity="center" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"/>

</TableRow>
</TableLayout>
</LinearLayout>
______________________________________________________________
linearlayout+relativelayout布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/system_text" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:id="@+id/username_test"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/username_test"
android:id="@+id/usercontent_test"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:layout_below="@id/usercontent_test"
android:layout_alignParentLeft="true"
android:id="@+id/password_test"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/usercontent_test"
android:layout_toRightOf="@id/password_test"
android:layout_marginLeft="13dp"
android:id="@+id/passcontent_test"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"
android:layout_below="@id/passcontent_test"
android:layout_alignParentLeft="true"
android:layout_marginLeft="60dp"
android:id="@+id/login_test"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/login_test"
android:layout_alignBottom="@+id/login_test"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:text="@string/cancel" />

</RelativeLayout>
</LinearLayout>
______________________________________________________________
string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">LayoutTestZy</string>
<string name="system_text">class3g系统</string>
<string name="username">用户名</string>
<string name="password">密码</string>
<string name="login">登录</string>
<string name="cancel">取消</string>
</resources>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值