立即注册

QQ登录

只需一步,快速开始

老冷编程学院

老冷培训班汇总介绍老冷付费工具汇总介绍老鬼UI编程学院EasyClick所有产品简介EasyClick官方交流群
IOS授权价格IOS/安卓 自助提卡链接安卓-中控群控-电脑授权-购买IOSusb版投屏群控教程IOS脱机版激活教程
IOS脱机版wifi局域网脚本中控教程IOS脱机版wifi局域网群控投屏教程远程调试frp,兼容安卓/IOS热更新工具,兼容安卓/IOS脱机版老冷网盘
查看: 946|回复: 0

[教程] 【EasyClick】【安卓UI】XML 基础教程~基本控件认识二

[复制链接] |主动推送

43

主题

19

回帖

3185

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3185
最后登录
2024-4-20
在线时间
440 小时

QQ认证

QQ
发表于 2023-3-15 19:27:02 | 显示全部楼层 |阅读模式

马上注册,解锁更多高级玩法

您需要 登录 才可以下载或查看,没有账号?立即注册

x
XML 基础教程~基本控件认识
教程原址:原生UI之常用控件二

CheckBox 复选框说明
复选框控件,用来让用户多个选择的控件.
私有属性

属性名
说明
可选值
layout_weight子元素权重
数字
当父级为LinearLayout的时候,子控件可以设置权重
gravity内部的控件对齐方式
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
checked是否选择
true:选中 false:不选中
text文字
字符串
textColor文字颜色
16进制,例如#FFFFFF
textSize文字大小
具体数字+dp
例子   
[XML] 纯文本查看 复制代码
<!-- 例子--> 
 <CheckBox android:tag="cb0"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:text="复选框0" />


RadioButton 单选按钮说明
单选按钮控件,用来让用户单选的控件
注意
单选按钮需要配合单选布局实现单选效果
私有属性
属性名
说明
可选值
layout_weight子元素权重
数字
当父级为LinearLayout的时候,子控件可以设置权重
gravity内部的控件对齐方式
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
checked是否选择
true:选中 false:不选中
text文字
字符串
textColor文字颜色
16进制,例如#FFFFFF
textSize文字大小
具体数字+dp
例子        
[XML] 纯文本查看 复制代码
'
<!--例子--> 
 <RadioButton android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:text="单选框1"                     android:textSize="15sp"                     android:gravity="center"                     android:checked="true" />
 



Spinner 下拉选择框说明
下拉选框


属性名
说明
可选值
layout_weight子元素权重
数字
当父级为LinearLayout的时候,子控件可以设置权重
gravity内部的控件对齐方式
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
text下拉文字
字符串
多个下拉选项用竖线分隔,例如:选项1|选型2
textColor文字颜色
16进制,例如#FFFFFF
textSize文字大小
具体数字+dp
defaultText默认选择的数据
text中的某一项
popupHeight弹出框高度
具体数字+dp
例子      
  
[XML] 纯文本查看 复制代码
 
 <!--例子-->
 <Spinner android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:text="选择1|选择2"                     android:textSize="15sp"                     android:gravity="center"                     android:defaultText="选择1"/>
 



Swtich 开关按钮说明
开关按钮
私有属性
属性名
说明
可选值
layout_weight子元素权重
数字
当父级为LinearLayout的时候,子控件可以设置权重
gravity内部的控件对齐方式
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
checked是否选择
true:选中 false:不选中
text文字
字符串
textColor文字颜色
16进制,例如#FFFFFF
textSize文字大小
具体数字+dp
例子        <!--例子-->        <Switch android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="开关"                android:textSize="15sp"                android:gravity="center"                android:checked="true" />Copy


ImageView 图像说明
图像控件
私有属性
属性名
说明
可选值
src图像地址
字符串
HTTP的URL或者IEC文件中的图像项目中res目录下的图像资源文件(@drawable/aaa这样的写法)
scaleType图像缩放方式
fitXY
fitCenter 默认
fitEnd
fitStart
center
centerCrop
centerInside
matrix
缩放方式参考:参考链接
例子      

[XML] 纯文本查看 复制代码
 
 <!--引用iec资源-->
 <ImageView android:layout_width="match_parent"                   android:layout_height="wrap_content"                   android:src="@drawable/a" />
 <!--引用网络资源图片地址-->
 <ImageView android:layout_width="match_parent"                   android:layout_height="wrap_content"                   android:src="http://baidu.com" />


WebView 内嵌浏览器说明
WebView 内嵌浏览器,支持 H5 和 JS 操作
私有属性
属性名
说明
可选值
url网页地址
支持layout内部的html,也支持http网络上的html
例子        


[XML] 纯文本查看 复制代码
<!--第一种 加载 layout 文件夹中的 html--> 
 <WebView android:layout_height="wrap_parent"                 android:layout_width="match_parent"                 android:url="main.html"/> 
 <!--第二种网络上的 html--> 
 <WebView android:layout_height="wrap_parent"                 android:layout_width="match_parent"                 android:url="https://www.baidu.com"/>


【老鬼教程】https://www.laoguicom.top/doc/2/
ROM定制、UI培训、UI定制
游客
回复
您需要登录后才可以回帖 登录 | 立即注册

关闭

想要力量吗骚年 上一条 /2 下一条

关闭

免责声明|Archiver|手机版|闽ICP备20013040号-2| 老冷编程学院 |网站地图

GMT+8, 2024-4-20 16:45

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表