Android之实现登陆页面分析
2016-06-15 14:34
381 查看
Android之实现登陆页面分析
二、登录界面的布局分析
1、login.xml
Step1:首先建立drawable 文件夹,创建logintopbg_roundcorner.xml
[html]
view plain
copy
<?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
[html]
view plain
copy
<?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
[html]
view plain
copy
<?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
[html]
view plain
copy
<?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 文件,布局如下
[html]
view plain
copy
<?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
[html]
view plain
copy
<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 SparseArray源码详解
- Android自定义视图 View 之重要知识点 Path 详解
- android手机推送视频到服务端
- Google Android开发者文档系列-开发企业App
- Android-Tab单选控件
- Android中Selector的用法
- 导入Android Studio工程
- Android简单的换肤demo
- Android 代码自动升级新版本更新apk时出现“已安装了存在签名冲突的同名数据包”
- 我的一些感悟——应聘Android开发工程师(2016届)
- 【Android】viewpager+fragment+tablayout实现滑动菜单栏
- Android问题记录
- EventBus使用详细讲解,结合示例
- Android笔记之开发中处理异常并写入本地log文件
- Android音视频之MediaPlayer音视频播放
- AndroidStudio:断点调试和高级调试
- Android开发笔记之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
- Android实现点击两次返回键退出
- Android实现界面完全全屏
- Android VideoView中getDuration()方法使用问题