Android之十一实现登陆页面分析
16lz
2021-01-23
Android之十一实现登陆页面分析
二、登录界面的布局分析
1、login.xml
Step1:首先建立drawable 文件夹,创建logintopbg_roundcorner.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#55ffffff"/><corners android:radius="15dp"/></shape>Step2:创建btn_select.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/btn_shape" android:state_pressed="false"></item> <item android:drawable="@drawable/btn_shape_after" android:state_pressed="true"></item></selector>其中btn_shape.xml 文件和btn_shape_after.xml 文件如下
btn_shape.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ff72CAE1"/> <corners android:radius="10dp"/></shape>btn_shape_after.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#87cefa"/> <corners android:radius="10dp"/></shape>Step3:定义login_tio.xml 文件,布局如下
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:background="@drawable/logintopbg_roundcorner" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".Loginactivity" ><EditText android:id="@+id/tdName" android:drawableLeft="@drawable/icons_user_img" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:ems="10" android:background="@android:drawable/edit_text" android:drawablePadding="10dp" android:hint="@string/etName" /><EditText android:id="@+id/tdPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="62dp" android:background="@android:drawable/edit_text" android:drawableLeft="@drawable/icons_password_img" android:drawablePadding="10dp" android:hint="@string/etPassword" android:ems="10" /><LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@id/tdPassword" > <Button android:id="@+id/button1" android:layout_width="50dp" android:layout_height="50dp" android:layout_weight="1" android:background="@drawable/btn_select" android:text="@string/btnlogin" /> <Button android:id="@+id/button2" android:layout_width="50dp" android:layout_height="50dp" android:background="@drawable/btn_select" android:layout_weight="1" android:layout_marginLeft="5dp" android:text="@string/btnRegister" /> </LinearLayout></RelativeLayout>
activity_main.xml
<span style="font-size:18px;"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/btn_shape" tools:context=".MainActivity" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="34dp" android:layout_marginRight="27dp" android:src="@drawable/monkey" /> <LinearLayout android:id="@+id/tt" android:layout_width="wrap_content" android:layout_height="wrap_content"> </LinearLayout> <TextView android:id="@+id/textView1" android:layout_width="80dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:text="@string/etPassword2" /> <include android:id="@+id/include1" android:layout_width="294dp" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" layout="@layout/login_top" /></RelativeLayout></span>
更多相关文章
- 界面布局
- Android 布局中 如何使控件居中
- android软键盘把页面挤上去的解决方法
- Android用ViewPager实现多页面的切换效果
- Android10共享文件总是读取不到文件,文件资源不存在!
- Android学习之文件存储
- Android中的布局管理
- Android InputStreamReader 解析gbk、gb2312编码的xml文件 编码