百分比适配
来源:互联网 发布:iphone 贵吗 知乎 编辑:程序博客网 时间:2024/05/20 15:59
首先,需要添加com.android.support:percent:24.1.1包,版本随意
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.1.1' compile 'com.android.support:percent:24.1.1'}
这个包给我们提供了PercentRelativeLayout以及PercentFrameLayout两种布局,
支持的属性有layout_widthPercent、layout_heightPercent、
layout_marginPercent、layout_marginLeftPercent、
layout_marginTopPercent、layout_marginRightPercent、
layout_marginBottomPercent、layout_marginStartPercent、layout_marginEndPercent
打开下载后的函数库,发现其中主要包含三个类。
PercentFrameLayout、PercentRelativeLayout、PercentLayoutHelper
大部分的百分比实现逻辑都在PercentLayoutHelper这个类中,首先我们需要知道,PercentFrameLayout、PercentRelativeLayout分贝继承于FrameLayout、RelativeLayout。原有的属性和方法都是可以使用的。同时PercentHelper还对其做了百分比布局的扩展,在xml文件中,增加了如下属性配置。
- heightPercent :百分比表示高度
- widthPercent :百分比表示宽度
- marginBottomPercent :百分比表示底部的间隔
- marginEndPercent:百分比表示距离最后一个View之间的间隔
- marginLeftPercent:百分比表示左边的间隔
- marginPercent :百分比表示View之间的间隔
- marginRightPercent:百分比表示右边的间隔
- marginStartPercent:百分比表示距离第一个View之间的间隔
- marginTopPercent:百分比表示顶部的间隔
下载地址:
http://blog.csdn.net/huningjun/article/details/47081519
阅读全文
1 0
- android 百分比适配
- Android百分比适配
- 百分比适配举例
- 百分比适配
- Android百分比适配
- Android屏幕适配,百分比布局
- Android屏幕适配,百分比布局
- 万能适配,百分比布局,支持padding
- 安卓学习--百分比适配
- android百分比布局学习,适配相关
- 关于android中的百分比适配
- android支持百分比的屏幕适配
- 屏幕适配之百分比方案详解
- 屏幕百分比适配的属性
- 安卓适配之终极方案,百分比适配
- 屏幕适配之百分比方案详解
- Android适配之百分比布局
- Android界面百分比适配-PercentRelativeLayout
- Unigine编辑器翻译为中文
- Ehcache与Redis对比
- 深入理解javascript中的立即执行函数(function(){…})()
- MATLAB 图像伪彩色处理
- Nginx服务器上软中断过高问题如何解决?
- 百分比适配
- IDEA热部署(四)---jetty服务器热部署项目
- 查找数字(一)
- 【opencv】3.mat和基本数据类型(开始)
- JAVA中的Thread.currentThread是什么意思
- mysql嵌套查询,快速插入大量数据
- #leetcode#305. Number of Islands II
- 照片后缀分组
- L2VPN与L3VPN的区别