Android百分比布局支持库介绍——com.android.support:percent(转)
转载自http://www.apkbus.com/forum.php?mod=viewthread&tid=244752&extra=&_dsign=0b699c42

获取支持库:
|
1
2
3
4
5
|
dependencies { compile 'com.android.support:percent:22.2.0'} |
新的布局组件:


新的属性设置:
- layout_widthPercent
- layout_heightPercent
- layout_marginPercent
- layout_marginLeftPercent
- layout_marginTopPercent
- layout_marginRightPercent
- layout_marginBottomPercent
- layout_marginStartPercent
- layout_marginEndPercent
使用介绍:
|
1
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
|
<android.support.percent.PercentFrameLayout android:layout_width="match_parent" android:layout_height="match_parent"/> <ImageView app:layout_widthPercent="50%" app:layout_heightPercent="50%" app:layout_marginTopPercent="25%" app:layout_marginLeftPercent="25%"/> </android.support.percent.PercentFrameLayout/> |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<android.support.percent.PercentRelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/top_left" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:background="#ff0000" app:layout_heightPercent="30%" app:layout_widthPercent="70%" /> <View android:id="@+id/top_right" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/top_left" android:background="#00ff00" app:layout_heightPercent="30%" app:layout_widthPercent="30%" /> <View android:id="@+id/centre" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@+id/top_left" android:background="#0000ff" app:layout_marginLeftPercent="10%" app:layout_marginRightPercent="20%" app:layout_marginTopPercent="10%" app:layout_marginBottomPercent="10%" app:layout_heightPercent="40%" /> <View android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/bottom" android:layout_below="@+id/centre" android:background="#00f0ff" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" app:layout_heightPercent="10%"/> </android.support.percent.PercentRelativeLayout> |

1、layout_marginTopPercent这种类型的参数具体的意义是什么?
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
|
<View android:id="@+id/centre" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@+id/top_left" android:background="#0000ff" app:layout_marginLeftPercent="10%" app:layout_marginRightPercent="20%" app:layout_marginTopPercent="10%" app:layout_marginBottomPercent="10%" app:layout_heightPercent="40%" /> |
2、控件设置的百分比是相对于屏幕还是相对于父容器而言呢?
|
1
2
3
4
5
6
7
8
9
|
<android.support.percent.PercentRelativeLayout android:layout_width="match_parent"android:layout_height="300dp"> |

|
1
2
3
4
5
6
7
8
9
|
<android.support.percent.PercentRelativeLayout android:layout_width="200dp"android:layout_height="match_parent"> |

Android百分比布局支持库介绍——com.android.support:percent(转)的更多相关文章
- Android百分比布局支持库(android-percent-support)
Android中提供了五种布局,其中用的最多的就是:LinearLayout, RelativeLayout 和 FrameLayout这三种布局,在对某一界面进行布局时最先想到也是通过这三种来布局的 ...
- Android百分比布局方案
百分比布局让其中的控件在指定高度,宽度,margin时使用屏幕宽高的百分比,不使用dp,px.这样一套布局可以适应多个屏幕,方便适配.如: app:layout_heightPercent=" ...
- Android 百分比布局库(percent-support-lib) 解析与扩展
转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46695347: 本文出自:[张鸿洋的博客] 一.概述 周末游戏打得过猛,于是周 ...
- Android百分比布局成功导入及简单使用
最近学习第一行代码第二版这本书,里面有介绍百分比布局的使用,经过一番摸索,终于是成功导入了百分比布局 就是这样,appcompat是25.3.1,那么百分比布局percent也是25.3.1 这样便是 ...
- [原]ffmpeg编译android 硬解码支持库 libstagefright
最近花了一天时间将ffmpeg/tools/build_stagefright执行成功,主要是交叉编译所需要的各种动态库的支持没链接上,导致各种报错,基本上网络上问到的问题我都碰到了,特此记录下来. ...
- Android 屏幕适配(二)增强版百分比布局库(percent-support-lib)
转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46767825: 本文出自:[张鸿洋的博客] 一 概述 上周一我们发布了Andr ...
- Android 增强版百分比布局库 为了适配而扩展
转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46767825: 本文出自:[张鸿洋的博客] 一 概述 上周一我们发布了Andr ...
- android support Percent支持库开发
Android的布局支持百分比的设置进行开发,来学习如何去实现它,不过看起来会像网页的设置,比如宽度的设置属性是`layout_widthPercent`.在此之前,我们一般都会设置Linearlay ...
- Android 支持库迁移到AndroidX
一.背景 Android系统版本在不断更新,从最初的Android 1.0到现在Google和各大手机厂商正在推的Android 10,平均下来每个年头都有一个大的版本更新.但用户正在用的手机上的An ...
随机推荐
- POJ1904 King's Quest(完备匹配可行边:强连通分量)
题目大概就是说给一张二分图以及它的一个完备匹配,现在问X部的各个点可以与Y部那些些点匹配,使得X部其余点都能找到完备匹配. 枚举然后匹配,当然不行,会超时. 这题的解法是,在二分图基础上建一个有向图: ...
- 最长上升子序列[LIS]
算法原理很简单,不再赘述,这里贴一个函数模板,传入的参数为序列首尾元素的指针. template<typename T> int LIS_nlogn(T * s, T * e) { ; T ...
- BZOJ4379 : [POI2015]Modernizacja autostrady
两遍树形DP求出每个点开始往上往下走的前3长路以及每个点上下部分的直径. 枚举每条边断开,设两边直径分别为$A,B$,则: 对于第一问,连接两边直径的中点可得直径为$\max(A,B,\lfloor\ ...
- 【BZOJ1060】[ZJOI2007]时态同步 树形DP
[BZOJ1060][ZJOI2007]时态同步 Description 小Q在电子工艺实习课上学习焊接电路板.一块电路板由若干个元件组成,我们不妨称之为节点,并将其用数字1,2,3-.进行标号.电路 ...
- 如何在2016年成为一个更好的Node.js开发者
本文主要讨论一些进行Node.js开发的最佳实践和建议,这些建议不仅仅适合开发者,还适合那些管理与维护Node.js基础架构的工作人员.遵循本文提供的这些建议,能够让你更好的进行日常的开发工作. St ...
- CF 7C. Line(扩展欧几里德)
题目链接 AC了.经典问题,a*x+b*y+c = 0整数点,有些忘记了扩展欧几里德,复习一下. #include <cstdio> #include <iostream> # ...
- mysql的小总结
1.什么是数据库 ? 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生于距今六十多年前,随着信息技术和市场的发展,特别是二十世纪九十年代以后,数据管理不再仅仅是存储和管理数 ...
- SQL 中怎么查询一个数据库中一共有多少个表
用户表:select count(*) 总表数 from sysobjects where xtype='u' 总表数:select count(*) 总表数 from sysobject s whe ...
- iBatis in 语句参数传入方法
刚刚开始在工作中用到iBatis 在用到in去查询或者删除 我本来是传递一个String的参数,但是总是报以下的错误
- 关于Jquery获取Table中td内的内容
$(this).children().eq(1).text()获取的是显示的值$(this).children().eq(1).html()获取的是<td></td>之间的所有 ...