android入门——UI(1)
一、使用TextView ImageView Button EditView做出登录页面
<?xml version="1.0" encoding="utf-8"?>
<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.ouc.wkp.ui1.MainActivity"> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#00f"> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:src="@drawable/more_arrow"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="小米账号登录"
android:textColor="#ffffff" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="注册"
android:textColor="#fff" />
</RelativeLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:orientation="vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="账号" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入邮箱/手机号码/小米账号" /> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:inputType="textPassword" /> </LinearLayout>
</LinearLayout> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="70dp"
android:text="登录" />
</LinearLayout>
activity_main.xml

二、使用ImageView CheckBox RadioButton
注意ImageView的scaleType属性,截图是麦子学院老师的课件


使用RadioButton注意要在外层包裹一个RadioGroup,每个RadioButton需要指定id
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"> <!-- scaleType默认情况下是fitCenter -->
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#f00"
android:scaleType="centerCrop"
android:src="@drawable/abc" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我喜欢的颜色" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="红色" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="蓝色" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="黑色" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="白色" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="紫色" />
</LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"> <RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RadioButton
android:id="@+id/boy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男" /> <RadioButton
android:id="@+id/girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" /> </RadioGroup>
</LinearLayout>
</LinearLayout>
imageview_index.xml

android入门——UI(1)的更多相关文章
- Android入门——UI(8)——Fragment(2)
先演示一下如何在一个activity中放置两个Fragment,先定义两个Fragment <?xml version="1.0" encoding="utf-8& ...
- Android入门——UI(9)
SwipRefreshLayout下拉刷新控件 <?xml version="1.0" encoding="utf-8"?> <android ...
- Android入门——UI(7)——Fragment
先上fragment静态加载的代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...
- android入门——UI(6)——ViewPager+Menu+PopupWindow
一.使用ViewPager开发新特性引导界面 <?xml version="1.0" encoding="utf-8"?> <Relative ...
- android入门——UI(5)
最近时间实在匆忙,博客的代码基本没有解释. 介绍ExpandableListView <?xml version="1.0" encoding="utf-8&quo ...
- android入门——UI(4)
GridView控件实现菜单 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...
- android入门——UI(3)
Spinner控件 ListView控件 一.Spinner控件 点击Spinner会弹出一个包含所有可选值的dropdown菜单,从该菜单中可以为Spinner选择一个新值. 有两种指定数据源的 ...
- Android入门——UI(2)
介绍SeekBar拖动条控件.ProgressBar进度条控件.DatePicker日历控件.TimePicker时间控件 <?xml version="1.0" encod ...
- 【详细】Android入门到放弃篇-YES OR NO-》各种UI组件,布局管理器,单元Activity
问:达叔,你放弃了吗? 答:不,放弃是不可能的,丢了Android,你会心疼吗?如果别人把你丢掉,你是痛苦呢?还是痛苦呢?~ 引导语 有人说,爱上一个人是痛苦的,有人说,喜欢一个人是幸福的. 人与人之 ...
随机推荐
- 二叉查找树的Insert和Delete操作
struct TreeNode{ SearchTree Left; SearchTree Right; ElementType Ele; }; /*递归一定有出口*/ /*递归代码就是要重复使用*/ ...
- Trafic control 大框图(HTB )
10.1. General diagram Below is a general diagram of the relationships of the components of a classfu ...
- hdu4740【杭州网赛、模拟、有点搜索?】
当时看了这题就感觉so easy... 本来不想写的,后来感觉是不是可以练一下搜索水平.. 比赛时有人过了就没写. 比赛完了写一下. 实现还不是那么顺利, 囧 本来自己以为这题能练下搜 ...
- 楼天城楼教主的acm心路历程(作为励志用)
楼主个人博客:小杰博客 利用假期空暇之时,将这几年GCJ,ACM,TopCoder 參加的一些重要比赛作个 回顾.昨天是GCJ2006 的回顾,今天时间上更早一些吧,我如今还清晰记得3 年 前,我刚刚 ...
- Service的基本组成
Service与Activity的最大区别就是一有界面,一个没有界面. 如果某些程序操作很消耗时间,那么可以将这些程序定义在Service之中,这样就可以完成程序的后台运行, 其实Service就是一 ...
- 学习Java这几个快捷键你得知道(不断更新中)
java中的System.out.println();的快捷键 --------先输入sysout 在按 alt + /
- Mustache学习
Mustache是基于JavaScript的一款模版Web引擎,Web 模板引擎是为了使用户界面与业务数据(内容)分离而产生的,它可以生成特定格式的文档,通常是标准的 HTML 文档. 一.Musta ...
- Android API Level在11前后及16之后时Notification的不同用法
作为刚入门Android的小白,最近在按照郭大神的<第一行代码>在练习,在用到Notification时遇到了一些问题,网上资料比较零散,我这里做了一个总结分析给各位,若有错误,恳请指正~ ...
- ssh框架用JUnit测试
public class testAuxDict { //读spring配置文件 public static BeanFactory factory = new ClassPathXmlApplica ...
- VMware vCenter Converter 使用,Error code: 2147549183 (0x8000FFFF) 解决方案
在实际生产环境中,为了节省成本,会将实体机转换为虚拟机,从而虚拟化. 在公司数据中心环境的中跑VMware vCenter ConverterStandalone Client 4.3,将其中一台on ...