Android-------模拟用户登录界面(优化1)
来源:互联网 发布:python的sleep函数 编辑:程序博客网 时间:2024/04/28 14:55
当基本的界面设置完成之后,我对基本界面做了一些简单的优化,使得看起来更加的美观和舒服。
一、边角框的使用
新建一个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <solid android:color="#FFFFFF" /> -->//这里设置自定义的颜色。本例使用#FFFFFF,如果为空则为透明
<corners android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"/>
<!-- 解释:solid的表示填充颜色,为了简单,这里用的是黑色。
而corners则是表示圆角,注意的是这里bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。
当然上面的效果也可以像下面一样设置,如下:
<corners android:radius="5dp" />
如果想引用这个xml,只需要@drawable/corners_bg.xml即可:
android:background="@drawable/corners_bg" -->
</shape>
然后在activity_main.xml中设置:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@drawable/background">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp">
<TableRow
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入用户名"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码"/>
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入密码"
android:inputType="textPassword"/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码"/>
<EditText
android:id="@+id/RePwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请再次输入密码"
android:inputType="textPassword"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别"/>
<RadioGroup
android:id="@+id/sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男"/><!-- 检查时候被选中 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "/>
<RadioButton
android:id="@+id/famle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"/>"
</RadioGroup>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="来自"/>
<Spinner
android:id="@+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱地址"/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:inputType="textEmailAddress"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱通知"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ToggleButton
android:id="@+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton"/>"
</FrameLayout><!-- 叠加的方式http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864899.html -->
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="同意条款"/>
<!-- http://www.cnblogs.com/wt616/archive/2011/06/20/2085368.html -->
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/btn_Regster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:text="注册"/>
<Button
android:id="@+id/btn_Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:layout_marginLeft="20dp"
android:text="取消"/>"
</LinearLayout>
</LinearLayout>
并添加了一张背景图片,如图:
设置了一下桌面的小图标:
如图:
设置的位置是:Androidmanifest.xml
中的:<application
android:allowBackup="true"
android:icon="@drawable/ic_luncher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ResultActivity"></activity><!--这里注意要把你的第二个activity写进去,因为Android系统首先加载的就是Androidmanifest.xml文件-->
</application>
- Android-------模拟用户登录界面(优化1)
- Android-------模拟用户登录界面(1)
- Android-------模拟用户登录界面(2)
- Android-------模拟用户登录界面(3)
- Android-------模拟用户登录界面(4)
- Android-------模拟用户登录界面(5)
- Android 用户登录界面
- Android-UI:用户登录界面
- 用户登录界面(代码)
- Android-数据储存:用户登录界面(存储)
- Google用户登录界面 Android实现
- 设计包含多种控件的用户登录界面(1)
- muloginscene(奇迹登录界面 模拟)开源
- 模拟QQ登录界面(frame)
- 模拟QQ登录界面
- 用户登录界面.cs
- 用户登录界面
- 用户登录界面
- 内部非比较排序---基数排序
- ios/android代码生成FLASH可用的actionscript代码(*.ane)
- onChange
- Volley 源码解析
- 四种方案解决ScrollView嵌套ListView问题
- Android-------模拟用户登录界面(优化1)
- SDN适用的网络
- android imageView 自适应大小
- fedora之硬盘扩容
- this和super
- 微信接口开发 控制层代码
- iOS自定义范围滑动条控件
- Factory mode
- 《iPhone 3D 编程》第一章:快速入门指南