在网上在到一个登录界面感觉挺不错的,给大家分享一下~先看效果图:
这个Demo除了按钮、小猫和Logo是图片素材之外,其余的UI都是通过代码实现的。
一、背景
背景蓝色渐变,是通过一个xml文件来设置的。代码如下:
background_login.xml
- <?xmlversion="1.0"encoding="utf-8"?>
-
<shapexmlns:android="http://schemas.android.com/apk/res/android">
-
<gradient
-
android:startColor="#FFACDAE5"
-
android:endColor="#FF72CAE1"
-
android:angle="45"
-
/>
-
</shape>
<?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>
startColor是渐变开始的颜色值,endColor是渐变结束的颜色值,angle是渐变的角度。其中#FFACDAE5中,FF是Alpha值,AC是RGB的R值,DA是RGB的G值,E5是RGB的B值,每个值在00~FF取值,即透明度、红、绿、蓝有0~255的分值,像要设置具体的颜色,可以在PS上的取色器上查看设置。
二、圆角白框
效果图上面的并不是白框,其实框是白色的,只是设置了透明值,也是靠一个xml文件实现的。
background_login_div.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
-
<shapexmlns:android="http://schemas.android.com/apk/res/android">
-
<solidandroid:color="#55FFFFFF"/>
- <!--设置圆角
-
注意:bottomRightRadius是左下角而不是右下角bottomLeftRadius右下角-->
-
<cornersandroid:topLeftRadius="10dp"android:topRightRadius="10dp"
-
android:bottomRightRadius="10dp"android:bottomLeftRadius="10dp"/>
-
</shape>
<?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>
三、界面的布局
界面的布局挺简单的,就直接贴代码啦~
login.xml
- <?xmlversion="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"/>
-
-
<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
-
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">
-
<TextViewandroid: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"/>
-
<ImageViewandroid:id="@+id/miniTwitter_logo"
-
android:src="@drawable/cat"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_alignParentRight="true"
-
android:layout_alignParentBottom="true"
-
android:layout_marginRight="25dp"
-
android:layout_marginLeft="10dp"
-
android:layout_marginBottom="25dp"/>
-
<ImageViewandroid:src="@drawable/logo"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_toLeftOf="@id/miniTwitter_logo"
-
android:layout_alignBottom="@id/miniTwitter_logo"
-
android:paddingBottom="8dp"/>
-
</RelativeLayout>
-
</LinearLayout>
<?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" />
<ImageView android:id="@+id/miniTwitter_logo"
android:src="@drawable/cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="25dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="25dp" />
<ImageView android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/miniTwitter_logo"
android:layout_alignBottom="@id/miniTwitter_logo"
android:paddingBottom="8dp"/>
</RelativeLayout>
</LinearLayout>
四、Java源文件
Java源文件比较简单,只是实例化Activity,去掉标题栏。
- packagecom.mytwitter.acitivity;
-
importandroid.app.Activity;
-
importandroid.os.Bundle;
-
importandroid.view.Window;
-
publicclassLoginActivityextendsActivity{
-
@Override
-
publicvoidonCreate(BundlesavedInstanceState){
-
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.login);
- }
- }
分享到:
相关推荐
android登陆界面设计,记住密码功能,登陆密码成功后进入APP
Android,APP登陆界面设计,界面优美简洁 ,值得大家下载使用。
想必大家都知道,一款手机APP必备的登录页面。这是你不错的选择。
对新手和老手都有意义的界面设计模式,不要错过
Android开发登陆界面布局
android漂亮的UI界面设计例子,平时做项目时在网上下载的,鉴于分享精神,上传上来。。。。。原型是一个公司程序员的公司任务设计,请别商用,要用请修改。。。
android客户端用户登陆界面,没有动作行为
Android开发的原生登陆界面。支持手机横屏和竖屏。
android 登陆界面例子 可以直接运行的
android QQ 登陆界面 绝对一模一样
Android qq界面的详细设计!相信对学习Android界面设计的人来说这个例子是很好的!~
声明:这也是我学习时在网上下载的,鉴于分享精神,并且觉得很不错才上传...android 漂亮的UI界面 完整的界面设计 这是一个完整的UI设计,但是没写动作,这是一个公司程序员的公司任务设计,请别商用,要用请修改。。。
Android QQ登录界面设计
特别适合初学者的登录界面的demo,严格按照课本上的结构,layout,main该有的都有
关于android软件开发的登陆界面,若为 新用户则可以跳转到注册界面
这里是一份自己设计的UI登陆界面,mock画出来的,前期比较有帮助。
安卓微信登陆界面,可直接部署运行。学习参考必备。
介绍了在android开发中的如何有效的设计界面。
适合Android初学者,主要介绍界面的一些功能
android ui设计 android源码 android开源项目 android项目代码 androidui设计,UI小练习