从零开始水安卓——UI初步

从零开始水安卓——UI布局

用户界面概述

UI组件结构

View(UI组件)

1.用于显示数据的组件

2.用于容纳组件的组件

Android中使用的数据单位

像素:px(pixels)

英寸:in(inches)

毫米:mm(Millimeters)

磅:pt(Points)

由于屏幕尺寸数量较多,所以实际上使用下面几种

dp:与密度无关的像素,在160dpi的屏幕上,1dp=1px=1/160英寸,且比例是保持不变的

dip:与dp相同

sp:与dp类似,与密度和字体缩放无关的像素,可以根据用户的字体大小首选项进行缩放

UI布局

布局概述

为UI提供一个可视化的结构。

对于一个activity或app widget,可以用如下方式声明布局

1.在XML中声明UI元素

2.在运行时实例化布局元素

LinnerLayout

线性布局,按照水平或垂直方向布局组件

宽度/高度/排列方向——可选择水平/垂直

分配空间(份数...)

布局之间可以嵌套

RelativelLayout

相对布局,用的最多的布局,工程建立默认的布局...

属性有一打

android:layout_above

android:layout_below

android:layout_toLeftOf(将该控件的右边缘和给定的ID的控件的左边缘对齐)

android:layout_toRightOf

android:layout_alignBaseline

android:layout_alignBottom

android:layout_alignLeft

android:layout_alignTop

android:layout_alignRight

android:layout_alignParentBottom(如果该值为true...)

android:layout_alignParentLeft

android:layout_alignParentRight

android:layout_alignParentTop

android:layout_centerHorizontal(如果该值为真,该控件将被置于水平方向的中央)

android:layout_centerVertical(垂直...)

android:layout_centerInParent(同时垂直和水平的...)

......

TableLayout

按行列方式(表格?)布局组件

<TableRow></TableRow>

然后具体的.这篇文章不错. mark一下

https://blog.csdn.net/lixpjita39/article/details/75303856

FrameLayout

帧布局,

依赖android:gravity 

如果没有特别的指定位置,元素会默认堆叠在左上角,并且后一个会覆盖前一个(?)

AbsoluteLayout

绝对布局,已被废弃,元素指定准确坐标后显示在屏幕上并允许元素间重叠。

GridLayout

网格布局,API14以后(Android4.0以后)。

传统LinerLayout实现网格效果有一定缺陷:

1.不能同时在xy方向对齐

2.多层布局嵌套性能问题

3.对编辑布局工具支持性不好

故诞生了该布局。

猜你喜欢

转载自blog.csdn.net/nishigesb123/article/details/88304305
今日推荐