码迷,mamicode.com
首页 > 其他好文 > 详细

MiniTwitter记住密码等功能实现

时间:2015-07-04 09:31:55      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

效果图如下:

技术分享

首先由界面图分析布局,基本可以分为三个部分,下面分别讲解每个部分。

       第一部分是一个带渐变色背景的LinearLayout布局,效果图如下:

技术分享

第二部分,红色线区域内,包括1,2,3,4  如图所示:

技术分享

 红色的1表示的是一个带圆角且背景色为#55FFFFFF(淡蓝色)的RelativeLayout布局,代码如下:

XML/HTML代码

<?xml version="1.0" encoding="UTF-8"?>  

<shape xmlns:android="http://schemas.android.com/apk/res/android">  

        <solid android:color="#55FFFFFF" />  

        <!-- 设置圆角   

        注意:        bottomRightRadius是左下角而不是右下角  bottomLeftRadius右下角-->  

        <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"  

                android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>  

</shape>  

       solid表示填充色,这里填充的是淡蓝色。corners是设置圆角。

接下来是区域2,为账号的文本和输入框,首先是账号的文本,代码如下:

XML/HTML代码

<TextView  

       android:id="@+id/login_user_input"  

        android:layout_width="wrap_content"  

        android:layout_height="wrap_content"  

        android:layout_alignParentTop="true"  

        android:layout_marginTop="5dp"  

        android:text="@string/login_label_username"  

        style="@style/normalText"/>  

定义账号的输入框,如下:

XML/HTML代码

<EditText  

        android:id="@+id/username_edit"  

        android:layout_width="fill_parent"  

        android:layout_height="wrap_content"  

        android:hint="@string/login_username_hint"  

        android:layout_below="@id/login_user_input"  

        android:singleLine="true"  

        android:inputType="text"/>  

 区域3是密码文本和输入框,同区域2,代码如下:

XML/HTML代码

<TextView  

     android:id="@+id/login_password_input"  

     android:layout_width="wrap_content"  

     android:layout_height="wrap_content"  

     android:layout_below="@id/username_edit"  

     android:layout_marginTop="3dp"  

     android:text="@string/login_label_password"  

     style="@style/normalText"/>  

<EditText  

     android:id="@+id/password_edit"  

     android:layout_width="fill_parent"  

     android:layout_height="wrap_content"  

     android:layout_below="@id/login_password_input"  

     android:password="true"  

     android:singleLine="true"  

     android:inputType="textPassword"  

/>  

       区域4,登录按钮:

XML/HTML代码

<Button  

      android:id="@+id/signin_button"  

      android:layout_width="wrap_content"  

      android:layout_height="wrap_content"  

      android:layout_below="@id/password_edit"  

      android:layout_alignRight="@id/password_edit"  

      android:text="@string/login_label_signin"  

      android:background="@drawable/blue_button"  

/> 

  第三部分:底下的文字和两张图片,分别标记了1,2,如图所示:

技术分享

  区域1:还是一个RelativeLayout,但这里设置的很简单,代码如下:

XML/HTML代码

<RelativeLayout  

      android:layout_width="fill_parent"  

      android:layout_height="wrap_content">  

</RelativeLayout>  

       区域2:"没有账号?注册"这几个文字定义在string里面,包含了一个<a>标签:

XML/HTML代码

<string name="login_register_link">没有帐号? <href="#" mce_href="#">注册</a></string>  

  定义如下:

XML/HTML代码

<TextView  android:id="@+id/register_link"  

    android:text="@string/login_register_link"  

    android:layout_width="wrap_content"  

    android:layout_height="wrap_content"  

    android:layout_marginLeft="15dp"  

    android:textColor="#888"  

    android:textColorLink="#FF0066CC"  

/>  

 实现miniTwitter登陆界面的具体步骤

       具体步骤如下:

       第一步:一些字符串定义

XML/HTML代码

<?xml version="1.0" encoding="utf-8"?>  

<resources>  

    <string name="hello">Hello World, LoginActivity!</string>  

    <string name="login_label_username">帐号</string>  

    <string name="login_label_password">密码</string>  

    <string name="login_label_signin">登 录</string>  

    <string name="login_status_logging_in">登录中...</string>  

    <string name="login_username_hint">Email或手机号</string>  

    <string name="login_register_link">没有帐号? <href="#" mce_href="#">注册</a></string>  

    <string name="app_name">miniTwitter</string>  

</resources>

第二步:

     XML/HTML代码

<?xml version="1.0" encoding="utf-8"?>  

<resources>  

        <style name="normalText" parent="@android:style/TextAppearance">                        

        <item name="android:textColor">#444</item>  

       <item name="android:textSize">14sp</item>  

        </style>  

</resources

第三步:背景色为渐变色

      XML/HTML代码

<?xml version="1.0" encoding="utf-8"?>  

<shape xmlns:android="http://schemas.android.com/apk/res/android">  

      <gradient  

           android:startColor="#FFACDAE5"  

           android:endColor="#FF72CAE1"  

           android:angle="45"  

      />  

</shape>  

 第四步:背景色味淡蓝色且为圆角

       XML/HTML代码

<?xml version="1.0" encoding="UTF-8"?>  

<shape xmlns:android="http://schemas.android.com/apk/res/android">  

        <solid android:color="#55FFFFFF" />  

        <!-- 设置圆角   

        注意:        bottomRightRadius是左下角而不是右下角  bottomLeftRadius右下角-->  

        <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"  

               android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>  

</shape>  

 第五步:

      XML/HTML代码

<?xml version="1.0" encoding="utf-8"?>  

<LinearLayout  

  xmlns:android="http://schemas.android.com/apk/res/android"  

  android:orientation="vertical"  

  android:layout_width="fill_parent"  

  android:layout_height="fill_parent"  

  android:background="@drawable/background_login">  

  <!-- padding 内边距   layout_margin 外边距   

                  android:layout_alignParentTop 布局的位置是否处于顶部 -->  

  <RelativeLayout  

          android:id="@+id/login_div"  

          android:layout_width="fill_parent"  

          android:layout_height="wrap_content"  

          android:padding="15dip"  

          android:layout_margin="15dip"  

          android:background="@drawable/background_login_div_bg"  

          >  

          <!-- 账号 -->  

          <TextView  

                  android:id="@+id/login_user_input"  

                  android:layout_width="wrap_content"  

                  android:layout_height="wrap_content"  

                  android:layout_alignParentTop="true"  

                  android:layout_marginTop="5dp"  

                  android:text="@string/login_label_username"  

                  style="@style/normalText"/>  

          <EditText  

                  android:id="@+id/username_edit"  

                  android:layout_width="fill_parent"  

                  android:layout_height="wrap_content"  

                  android:hint="@string/login_username_hint"  

                  android:layout_below="@id/login_user_input"  

                  android:singleLine="true"  

                  android:inputType="text"/>  

    <!-- 密码 text -->  

    <TextView  

            android:id="@+id/login_password_input"  

            android:layout_width="wrap_content"  

            android:layout_height="wrap_content"  

            android:layout_below="@id/username_edit"              

            android:layout_marginTop="3dp"  

            android:text="@string/login_label_password"  

            style="@style/normalText"/>  

    <EditText  

            android:id="@+id/password_edit"  

            android:layout_width="fill_parent"  

            android:layout_height="wrap_content"  

            android:layout_below="@id/login_password_input"  

            android:password="true"  

            android:singleLine="true"  

            android:inputType="textPassword"  

    />  

    <!-- 登录button -->  

    <Button  

            android:id="@+id/signin_button"  

            android:layout_width="wrap_content"  

            android:layout_height="wrap_content"  

            android:layout_below="@id/password_edit"  

            android:layout_alignRight="@id/password_edit"  

            android:text="@string/login_label_signin"  

            android:background="@drawable/blue_button"  

    />  

  </RelativeLayout>  

  

  

  <RelativeLayout  

      android:layout_width="fill_parent"  

      android:layout_height="wrap_content"  

      >  

         <TextView  android:id="@+id/register_link"  

             android:text="@string/login_register_link"  

             android:layout_width="wrap_content"  

             android:layout_height="wrap_content"  

             android:layout_marginLeft="15dp"  

             android:textColor="#888"  

             android:textColorLink="#FF0066CC"  

          />  

       </RelativeLayout>  

  </LinearLayout>  

MiniTwitter记住密码等功能实现

标签:

原文地址:http://www.cnblogs.com/w411601/p/4620154.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!