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
    评论
Material 3 是 Google 最新推出的 Material Design UI 组件库。以下是一个简单的 Android 登录布局的 Material 3 实现示例: 首先,在项目的 build.gradle 文件中添加以下依赖项: ```groovy dependencies { implementation 'com.google.android.material:material:1.5.0-alpha02' } ``` 然后,在布局文件中添加以下代码: ```xml <com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Email" app:helperText="Enter your email address" app:startIconDrawable="@drawable/ic_email"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Password" app:helperText="Enter your password" app:startIconDrawable="@drawable/ic_password" app:endIconDrawable="@drawable/ic_visibility_off" app:endIconMode="password_toggle"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.button.MaterialButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="LOGIN" /> ``` 这里使用了 TextInputLayout 和 TextInputEditText 来创建输入框,以及 MaterialButton 来创建登录按钮。 最后,可以自定义 startIconDrawable、endIconDrawable、helperText 等属性来美化布局。 这是一个基本的 Material 3 登录布局实现,你可以根据自己的需求进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值