EasyClik安卓原生UI免费版教程
免费教程说明
UI入门
EasyClick 官方支持的安卓组件
排版绘制
↗
布局
↗
LinearLayout 线性布局
RadioGroup 单选布局
ScrollView 垂直滚动框布局
FrameLayout 帧布局
HorizontalScrollView 横向滚动框
CardView卡片布局
include 引用布局
控件
↗
TextView 控件
View 视图
EditText 输入框控件
Button 按钮控件
CheckBox 复选框
RadioButton 单选按钮
Spinner 下拉选择框
Swtich 开关按钮
ImageView 图像
WebView 内嵌浏览器
公有属性表
人机交互
↗
按钮点击操作
单选按钮,复选框,开关选中操作
下拉框选中操作
修改文本内容
保存UI参数脚本读取值
UI中启动脚本
UI中启动EC设置
清空UI参数
对话框
悬浮窗
脚本与 UI 交互
UI与网络交互
原生UI 学习思路
本站点使用 MrDoc 构建
-
+
UI入门
# UI入门 ## 什么是UI UI设计(或称界面设计)是指对软件的人机交互、操作逻辑、界面美观的整体设计。UI设计分为实体UI和虚拟UI,互联网常用的UI设计是虚拟UI,UI即User Interface(用户界面)的简称。 ## 什么是原生XML UI 所谓的原生XMLUI 指的是 安卓原生UI ,安卓的原生UI 使用的文件为XML文件,以标签的方式编写,由java解析后成为我们能看到的手机APP界面. ## XML 扫盲认知 ### XML 文件说明 XML 指可扩展标记语言(eXtensible Markup Language)。 资料:[xml菜鸟教程](https://www.runoob.com/xml/xml-tutorial.html) 例子 ```xml <?xml version="1.0" encoding="utf-8"?> <!-- 标签头--> <a> <!-- 子标签头 --> <b> <c> </c> </b> <!-- 子标签尾 --> <!-- 子标签头--> <b1> <!-- 子标签头--> <c> </c> <!-- 子标签尾--> </b1> <!-- 子标签尾--> <!-- 自闭合标签 --> <d /> </a> <!-- 标签尾-- > ``` ### Android布局xml文件 #### 国际标准格式 AndroidStudio自动创建的MainActivity布局 ```xml <?xml version="1.0" encoding="utf-8"?> <!-- 第一行声明是个xml 文件 编码UTF-8 --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <include layout="@layout/layout_test" /> </androidx.constraintlayout.widget.ConstraintLayout> ```` #### EasyClick 标准格式 <font color="00ffff">说明:原生UI项目里才有下图所示的资源文件。</font>  原生UI模版自动创建的main.xml布局 ```xml <?xml version="1.0" encoding="UTF-8" ?> <!-- 第一行声明是个xml 文件 编码UTF-8 --> <ScrollView xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:android="http://schemas.android.com/apk/res/android" xsi:noNamespaceSchemaLocation="layout.xsd" android:layout_height="match_parent" android:layout_width="match_parent" > <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:padding="20dp" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="表单开始,设置tag属性,用于在代码里面获取对应的值"/> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <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:tag="name" android:hint="请输入姓名"/> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <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:tag="age" android:hint="请输入年龄"/> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="性别: "/> <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="sex" android:text="男同学|女同学"/> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="喜欢玩"/> <EditText android:layout_width="100dp" android:layout_height="wrap_content" android:gravity="center_horizontal" android:tag="a1" android:hint="什么"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="和"/> <EditText android:layout_width="100dp" android:gravity="center_horizontal" android:layout_height="wrap_content" android:tag="a2" android:hint="什么"/> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="爱 好: "/> <LinearLayout android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="match_parent"> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="music" android:text="听音乐"/> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="sing" android:text="唱歌"/> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="dance" android:text="跳舞"/> </LinearLayout> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="所在年级: "/> <RadioGroup android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="match_parent"> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="one" android:text="一年级"/> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="two" android:text="二年级"/> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="three" android:text="三年级"/> </RadioGroup> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical" android:layout_width="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:text="备注: "/> <EditText android:layout_width="match_parent" android:layout_height="200dp" android:tag="mark" android:minHeight="100dp" android:maxLines="1000" android:hint="备注"/> </LinearLayout> </LinearLayout> </ScrollView> ```` ## EasyClick 官方标准解释 >s **第一行是必须有的。否则Android无法解析布局文件** 这表示是一个xml 格式的文件 编码UTF-8 。 ```xml <!-- 第一行声明是个xml 文件 编码UTF-8 --> <?xml version="1.0" encoding="UTF-8" ?> ```` >s **第二行的标签** 形如下面的xml代码 ```xml <ScrollView xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:android="http://schemas.android.com/apk/res/android" xsi:noNamespaceSchemaLocation="layout.xsd" android:layout_height="match_parent" android:layout_width="match_parent" > <!-- 这里面写子布局--> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:padding="20dp" > <!-- 这里面写子布局或者 子控件--> </LinearLayout> </ScrollView> ```` >d **说明:**1. 第一行:声明ScrollView布局的基本布局 ,<font color="ff0000">必须有,可以换成其他布局:线性布局等</font>。 2. 第二行:**xmlns:xsi** 解析格式 ,<font color="ff0000">必须有,**不可更改**</font>。 3. 第三行:**xmlns:android** 表示Android布局引用资源路径,<font color="ff0000">必须有,**不可更改**</font>。 4. 第四行:**xsi:noNamespaceSchemaLocation** 表示EasyClick 官方的解析布局的资源 ,<font color="ff0000">必须有,**不可更改**</font>。 5. 第五行:**android:layout_height** 布局的高度 , <font color="ff0000">必须有,按需更改</font>。 6. 第六行:**android:layout_width** 布局的宽度 ,<font color="ff0000">必须有,按需更改</font>。 7. **特别说明**: 子布局和子控件不需要 **第二行** 至 **第四行** 的内容。 8. EasyClick 中使用tag 属性代替Android的 id属性。 AndroidXML布局规范:[谷歌官方规范](https://developer.android.google.cn/guide/topics/ui) 其他资料参考:[安卓开发常用的布局](https://blog.csdn.net/diandianxiyu_geek/article/details/78923274) 我是Mr-老鬼、QQ1156346325 。 **----------版权声明-----------------** 本文版权所有~Mr-老鬼 ~转载请注明原文地址 免责声明:本文所有的教程仅限交流学习使用不得用于违法用途,造成的法律后果本人不承担责任。
Mr、老鬼
2024年1月23日 16:56
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
PDF文档(打印)
分享
链接
类型
密码
更新密码