(菜鸟篇):1.android登录界面
2016-04-01 15:59
429 查看
大家先看效果图:
1.login.xml
<LinearLayoutandroid:id="@+id/login_input01"android:layout_below="@id/zx_text"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:layout_marginLeft="5dp"android:layout_marginRight="5dp"android:gravity="center_vertical"android:orientation="horizontal"<span style="color:#cc0000;">android:addStatesFromChildren="true"//这个很重要,</span><span style="color: rgb(204, 0, 0); font-family: Arial, Helvetica, sans-serif; "><em><span style="color:red;">从子控件</span></em></span><span style="color: rgb(204, 0, 0); font-family: Arial, Helvetica, sans-serif; "><u><span style="color:red;"><EditText></span><span style="color:red;">中获取焦点</span></u></span>android:background="@drawable/input_box_selector"><ImageViewandroid:id="@+id/user_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="15dp"android:layout_marginRight="8dp"android:background="@drawable/name"android:clickable="true" /><<span style="color:#ff0000;">EditText</span>android:id="@+id/user_name"android:layout_width="fill_parent"android:layout_height="40dp"android:paddingLeft="10dp"android:maxLength="20"android:singleLine="true"<span style="color:#ff0000;">android:background="@null" </span>/></LinearLayout><LinearLayoutandroid:id="@+id/login_input02"android:layout_below="@id/login_input01"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="8dp"android:layout_marginLeft="5dp"android:layout_marginRight="5dp"android:gravity="center_vertical"android:addStatesFromChildren="true"android:orientation="horizontal"android:background="@drawable/input_box_selector"><ImageViewandroid:id="@+id/lock_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="15dp"android:layout_marginRight="8dp"android:background="@drawable/password"android:clickable="true" /><EditTextandroid:id="@+id/user_password"android:layout_width="fill_parent"android:layout_height="40dp"android:paddingLeft="10dp"android:layout_centerHorizontal="true"<span style="color:#ff6600;">android:inputType="textPassword"</span>android:maxLength="20"android:password="true"<span style="color:#ff0000;">android:background="@null"</span>/></LinearLayout>
<LinearLayoutandroid:id="@+id/linearlayout"android:layout_below="@id/login_input02"android:layout_width="match_parent"android:layout_height="40dp"android:layout_marginTop="5dp"android:orientation="horizontal"><CheckBoxandroid:id="@+id/login_checkBox"<span style="color:#ff0000;">style="@style/MyCheckBox"</span>android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginRight="3dp"android:scaleX="0.5"android:scaleY="0.5"android:text="@string/login_remember_psw"android:textColor="#777"android:textSize="32sp" /><TextViewandroid:id="@+id/forget_pwd"android:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:text="@string/forget_pwd"android:textSize="16sp"android:textColor="#777"android:gravity="center"android:layout_gravity="center_vertical"android:layout_marginLeft="10dp"android:layout_marginRight="30dp"/></LinearLayout>
<Buttonandroid:id="@+id/login_button"android:layout_below="@id/linearlayout"android:layout_width="fill_parent"android:layout_height="35dp"android:layout_marginLeft="15dp"android:layout_marginRight="15dp"android:layout_marginTop="10dp"android:layout_centerHorizontal="true"android:text="@string/login_button"android:textColor="#ffffff"android:background="@drawable/login_button_selector"/><TextViewandroid:id="@+id/register_now"android:layout_below="@id/login_button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="45dp"android:text="@string/register_now"android:layout_centerInParent="true"android:textColor="#ff0000"android:textSize="18sp"/>
2.自定义显示效果
input_box_selector.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" ><item android:state_focused="false" android:drawable="@drawable/input_normal" /><item android:state_focused="true" android:drawable="@drawable/input_focused" /></selector>input_normal.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!-- 描边 --><strokeandroid:width="1dp"android:color="#cccccc" /><!-- 设置按钮的四个角为弧形 --><corners android:radius="10dp" /></shape>input_focused.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!-- 描边 --><strokeandroid:width="1dp"android:color="#c70900" /><!-- 设置按钮的四个角为弧形 --><corners android:radius="10dp" /></shape>3.res下values下styles.xml中添加
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox"><item name="android:button">@drawable/login_checkbox_style</item></style>login_checkbox_style.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" ><item android:drawable="@drawable/checkbox_clickred" android:state_checked="true"/><item android:drawable="@drawable/checkbox_click" android:state_checked="false"/><item android:drawable="@drawable/checkbox_click"/></selector>checkbox_clickred.png
checkbox_click.png
是两张图片4.该登录按钮的自定义选择器login_button_selector.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" ><item android:state_pressed="false"><shape android:shape="rectangle" ><!-- 填充的颜色在strings里面 --><solid android:color="@drawable/clr_normal"></solid><!-- 设置按钮的四个角为弧形 --><corners android:radius="10dp" /></shape></item><item android:state_pressed="true"><shape android:shape="rectangle"><!-- 填充的颜色在strings里面 --><solid android:color="@drawable/clr_pressed" /><!-- 设置按钮的四个角为弧形 --><corners android:radius="10dp" /></shape></item></selector>res下values下strings.xml里
<resources><drawable name="clr_normal">#c70900</drawable><drawable name="clr_pressed">#FF3333</drawable><span style="font-family: Arial, Helvetica, sans-serif;"> </span>
<pre name="code" class="html"> <string name="forget_pwd">忘记密码?</string><string name="login_button">登录</string><string name="login_remember_psw">记住密码</string><string name="register_now">还没有账号,立即注册</string>
</resources>
相关文章推荐
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- 【Android】Android 登录界面设计和网络连接及验证登录
- Android实现闪屏及注册和登录界面之间的切换效果
- 记住密码(Android登录界面)
- 28. android——miniTwitter登录界面 详解
- Android实现注册登录界面的实例代码
- Android实现登录界面和功能实例
- Android 记住密码和自动登录界面的实现(SharedPreferences 的用法)
- Android打开界面时判断是否登录,未登录跳转登录界面,登录完成后直接跳转要打开的界面
- Android 圆角边框登录界面
- 【Android】用户登录注册界面开发及用户信息管理案例代码详解
- android 手机登录界面程序1(转载+修改)
- Android-------模拟用户登录界面(1)
- Android 用户登录界面
- android app从登录界面进入主页,按home键回桌面再进入app,重新弹出登录界面的问题解决
- Android-------模拟用户登录界面(3)
- Android 简单EventBus登录界面与传值(粘性事件)