当前位置:首页 » 安卓系统 » 登录界面android

登录界面android

发布时间: 2025-02-02 07:53:23

1. 如何设计android的登录界面

在网上在到一个登录界面感觉挺不错的,给大家分享一下~先看效果图:

这个Demo除了按钮、小猫和Logo是图片素材之外,其余的UI都是通过代码实现的。

?

一、背景

背景蓝色渐变,是通过一个xml文件来设置的。代码如下:

background_login.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:andro>
<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

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:andro>
<solid android:color="#55FFFFFF" />
<!-- 设置圆角
注意: bottomRightRadius是左下角而不是右下角 bottomLeftRadius右下角-->
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>
</shape>

?

三、界面的布局

界面的布局挺简单的,就直接贴代码啦~

login.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:andro
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:
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:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="@string/login_label_username"
/>
<EditText
android:
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:
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"
/>
<EditText
android:
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:
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:
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:
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>

2. 如何使用Android Studio开发用户登录界面

在Android Studio开发用户登录界面时,首先确保你已配置好基本运行环境及SDK。项目开始前,通过右键点击new->Mole,选择Android Application,并将其名称改为你的项目名称。同时选择支持的Android版本。接下来选择Blank Activity,然后点击next,直至最后点击finish完成项目的创建。

在project目录下,你会看到新创建的登录项目。展开res/layout文件夹,点击打开activity_main.xml文件,这里你将编写登录界面。这是初始的主界面,尚未经过我们编写的界面。Android Studio提供了一个强大的预览功能,非常实用。

将activity_main.xml的代码替换成以下内容:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:gravity="center_vertical" android:stretchColumns="0,3">

<TextView android:text="账 号:" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24px" />

<EditText android:id="@+id/account" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24px" android:minWidth="220px"/>

<TextView android:text="密 码:" android:layout_width="wrap_content" android:layout_height="wrap_content" />

<EditText android:id="@+id/pwd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="220px" android:textSize="24px" android:inputType="textPassword"/>

<Button android:id="@+id/login" android:text="登录" android:layout_width="wrap_content" android:layout_height="wrap_content" />

<Button android:id="@+id/quit" android:text="退出" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

完成上述代码替换后,使用Android手机进行测试,大功告成。

你的支持是我前进的动力,记得给予好评和采纳,答题不易,互相帮助。

3. 如何使用Android Studio开发用户登录界面

一个登录界面需要有:

  1. 登录、注册按钮(Button)

  2. 用户名、密码输入框(TextView,EditView)

  3. 用户协议连接

  4. 忘记密码按钮


想好的有哪些控件后,开始设计界面大概样式,比如这个样子:

安卓登录界面就写完了。

热点内容
滑板鞋脚本视频 发布:2025-02-02 09:48:54 浏览:432
群晖怎么玩安卓模拟器 发布:2025-02-02 09:45:23 浏览:557
三星安卓12彩蛋怎么玩 发布:2025-02-02 09:44:39 浏览:743
电脑显示连接服务器错误 发布:2025-02-02 09:24:10 浏览:536
瑞芯微开发板编译 发布:2025-02-02 09:22:54 浏览:146
linux虚拟机用gcc编译时显示错误 发布:2025-02-02 09:14:01 浏览:232
java驼峰 发布:2025-02-02 09:13:26 浏览:651
魔兽脚本怎么用 发布:2025-02-02 09:10:28 浏览:532
linuxadobe 发布:2025-02-02 09:09:43 浏览:212
sql2000数据库连接 发布:2025-02-02 09:09:43 浏览:726