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,你会心疼吗?如果别人把你丢掉,你是痛苦呢?还是痛苦呢?~ 引导语 有人说,爱上一个人是痛苦的,有人说,喜欢一个人是幸福的. 人与人之 ...
随机推荐
- SQL server指定随机数范围
declare @randnum int=0declare @startnum int =0declare @endnum int=0 set @startnum = 150 set @endnum ...
- 测试中的代码分享~将可以合并的方法去合并Func不赖
在面向对象的设计中,我们经常会谈到“重构”,而重构之中有个叫合并方法的,就是将多个方法干的事类似,或者说,方法体的长向很像,那么,我们需要去考虑,将它们进行抽象! 原来的代码: /// <sum ...
- POJ2063 Investment 【全然背包】
Investment Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8019 Accepted: 2747 Descri ...
- BCTF warmup 50
这是一道关于RSA的解密题:首先,我们要明白,通常是公钥加密.私钥解密,私钥签名.公钥验证.这个题目中给出的是一个公钥和一段密文. 刚开始一直以为和验证签名有关,费劲脑汁也想不出来怎么办.下面介绍些思 ...
- Java基础笔记-抽象,继承,多态
抽象类: abstract修饰 抽象方法必须定义在抽象类中,抽象类不能创建对象. 在抽象方法中可以不定义抽象方法,作用是:让该类不能建立对象. 特点是: 1.定义在抽象类中 2.方法和类都用abstr ...
- css3教程:弹性盒模型
Css3引入了新的盒模型——弹性盒模型,该模型决定一个盒子在其他盒子中的分布方式以及如何处理可用的空间.这与XUL(火狐使用的用户交互语言)相似,其它语言也使用相同的盒模型,如XAML .GladeX ...
- log4j异常问题
log4j:WARN No appenders could be found for logger 转自:最爱NBA 直接写我的解决办法:在src下面新建file名为log4j.propertie ...
- Ubuntu下使用Vi时方向键变乱码 退格键不能使用的解决方法
要在Ubuntu下编辑一些文件,这就涉及到了vi这个编辑器了.在Ubuntu下,初始使用vi的时候有点问题,就是在编辑模式下使用方向键的时候,并不会使光标移动,而是在命令行中出现[A [B [C [D ...
- Linux学习之停止进程
首先,用ps查看进程,方法如下: ps -ef ……smx 1822 1 0 11:38 ? 00:00:49 gnome-terminalsmx 18 ...
- <s:if>标签与ActionContext.getContext().getSession()
今天在做<s:if>标签中的属性值从 ActionContext.getContext().getSession().put("WW_TRANS_I18N_LOCALE" ...