Android实现简易登录界面详解
来源:互联网 发布:淘宝信用卡哪个银行好 编辑:程序博客网 时间:2024/06/04 01:36
效果图:
1、选择LinearLayout作为总的布局方式
<LinearLayout 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:orientation="vertical"
tools:context="com.example.testlogin.MainActivity"
2、编写--用户注册--这一部分,选择textview
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:textSize="20sp"
android:text="@string/resister" />
3、编写用户名、密码和两个输入框(选择relativelayout布局)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:textSize="18sp"
android:id="@+id/username"/>
<EditText
android:hint="请输入用户名"
android:inputType="text"
android:id="@+id/userinput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/username"
android:layout_alignBaseline="@+id/username"
android:textSize="18sp"
android:background="@null"/>
注意:第一个输入框在用户名的右边( android:layout_toRightOf="@+id/username"),密码在用户名下面( android:layout_below="@+id/username" )
对齐基准线( android:layout_alignBaseline="@+id/username")。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密 码:"
android:textSize="18sp"
android:layout_below="@+id/username"
android:layout_marginTop="20dp"
android:id="@+id/password"/>
<EditText
android:hint="请输入密码"
android:paddingLeft="0dp"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/passinput"
android:layout_toRightOf="@+id/password"
android:layout_alignLeft="@+id/userinput"
android:layout_below="@+id/username"
android:layout_alignBaseline="@+id/password"
/>
</RelativeLayout>
4、单选按钮 性别部分,选择linearlayout布局,“男”和“女”权重设置为1,就可以平分剩余空间
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical"//设置垂直居中
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性 别 :"
android:textSize="18sp"
/>
<RadioGroup
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"
android:layout_weight="1"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="女"/>
</RadioGroup>
</LinearLayout>
5、爱好和三个checkbox按钮,同样采用LinearLayout布局方式,三个checkbox权重分别设置为1,就可以平分剩余空间
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="爱 好:"
android:textSize="18sp"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="唱歌"
android:layout_weight="1"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="跳舞"
android:layout_weight="1"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="运动"
android:layout_weight="1"/>
</LinearLayout>
6、添加登录按钮
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"/>
如果有小伙伴觉得我写的对的,请顶一下这篇博文。
- Android实现简易登录界面详解
- 在Android中实现简易的登录界面
- Android一个简易的登录界面
- Android实现登录界面功能和实现详解
- Android实战简易教程-第三十二枪(自定义View登录注册界面EditText-实现一键清空)
- Android实战简易教程-第三十二枪(自定义View登录注册界面EditText-实现一键清空)
- Android实战简易教程<三十二>(自定义View登录注册界面EditText-实现一键清空)
- 简易的登录界面
- Android 客户端登录界面实现
- Android 登录界面的实现
- android 登录界面功能实现
- Android登录界面的实现
- 【Android】登录界面的实现
- android实现登录注册简易代码
- Android_登录界面功能和实现详解
- android——miniTwitter登录界面 详解
- android——miniTwitter登录界面 详解
- Struts2实现简易登录
- Gauss-Newton算法学习
- 图片懒加载的几种实现
- 粟裕九原则
- OLED GUI
- bind和on的区别
- Android实现简易登录界面详解
- Xmind基础教程-下钻和上钻
- Ubuntu14.04重装后reinstall一些东西
- 摘抄自 老廖关于 线程 IO 的讲解 很独到易懂 总之情不自禁的转载了 以便 温故知新
- phpstudy虚拟目录的设置
- Android系统中aidl的理解和service的添加
- MyEclipse 安装 SVN 插件
- C语言helloworld
- opencv学习中——bat批处理图片