Android UI 开发
来源:互联网 发布:八本兵种等级数据 编辑:程序博客网 时间:2024/05/18 21:07
Android UI 开发
Android中的UI
Android应用的界面是由View和ViewGroup对象构建的。它们有很多种类,并且都是View类的子类。
ViewGroup是View的一个扩展,可以容纳多个View,通过ViewGroup类可以创建有联系的子View组成的复合控件。
线性布局(LinearLayout)
线性布局是Android中较为常用的布局方式,它使用<LinearLayout>标签。线性布局主要有两种形式,一种是水平线性布局,一种是垂直线性布局,如图所示:
UI界面的开发
1.在Androidstudio开发环境中建立UI界面切换至Android视图依次打开app-res-layout,在layout中选择新建XML文件(linearlayoutdemo1.xml)编写如下代码,通过修改代码进行线性布局的水平或者垂直两种形式的转换,其代码如下:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"
/>
2.区分属性
android:layout_gravity用于指定控件在布局中的对齐方式。
android:gravity用于指定文字在控件中的对齐方式。
建立名为linearlayoutdemo2.xml的XML文件进行UI界面中控件的位置变换,代码如下:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:text="Button1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Button3"
/>
UI界面效果如图
3.重要属性—android:layout_weight
android:layout_weight属性允许我们使用比例的方式来指定空间的大小,它在手机屏幕的适配性方面可以起到非常重要的作用。
建立名为linearlayoutdemo3.xml的XML文件运用android:layout_weight属性编写如下代码:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Type someting"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"/>
UI界面呈现如下效果,体现了 android:layout_weight属性的适配性。
- Android开发UI界面设计
- android ui 开发总结
- android ui 开发
- Android UI开发专题
- Android开发UI特效
- Android UI开发
- Android开发-UI
- Android UI 开发
- Android UI 开发
- Android UI开发----国际化
- Android UI的开发
- Android开发之UI
- Android开发-UI布局
- android积累----桌面UI开发
- Android UI开发第二十篇
- Android UI开发【开篇导航】
- Android : UI开发ActionBar页眉
- Android应用开发-UI适配
- AS断点调试与高级调试(二)
- 习题3-3 数数字
- 下拉菜单思路及实现
- 《peopleware》摘抄(二)
- BFS 走迷宫
- Android UI 开发
- 【Leetcode题解】258.Add Digits
- 【Android develop】【学习笔记005】打开另一个activity
- 258. Add Digits
- cocos2d
- poj 2524 Ubiquitous Religions
- (转)Android RecyclerView 使用完全解析 体验艺术般的控件
- CFree “undefined reference to `__dyn_tls_init_callback'” 的解决方法
- C++运算符重载——重载二元运算符