安卓百分比布局
来源:互联网 发布:淘宝如何开天猫店 编辑:程序博客网 时间:2024/06/05 04:04
一、导入(最新详见https://github.com/hongyangAndroid/android-percent-support-extend)
compile 'com.zhy:percent-support-extends:1.1.1'二、属性(以PercentLinearLayout为例,另外还支持PercentFrameLayout,PercentRelativeLayout以及嵌套ScrollView的PercentLinearLayout)
###支持的属性 :
- layout_heightPercent
- layout_widthPercent
- layout_marginBottomPercent
- layout_marginEndPercent
- layout_marginLeftPercent
- layout_marginPercent
- layout_marginRightPercent
- layout_marginStartPercent
- layout_marginTopPercent
- layout_textSizePercent
- layout_maxWidthPercent
- layout_maxHeightPercent
- layout_minWidthPercent
- layout_minHeightPercent
- layout_paddingPercent
- layout_paddingTopPercent
- layout_paddingBottomPercent
- layout_paddingLeftPercent
- layout_paddingRightPercent
对于值可以取:10%w , 10%h , 10% , 10%sw , 10%sh
一看就明白怎么用了
<?xml version="1.0" encoding="utf-8"?><com.zhy.android.percent.support.PercentLinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- 后缀: h:父控件高度 w:父控件宽度 sh:屏幕高度 sw:屏幕宽度 不加后缀: 1.这个一般是长方形的 app:layout_heightPercent="50%"//父控件高度50% app:layout_widthPercent="50%"//父控件宽度50% 2.这个是正方形的 app:layout_heightPercent="50%h" app:layout_widthPercent="50%h" 3. top和bottom为父控件高度的5% left和right为父控件宽度的5% app:layout_marginPercent="5%" 4.字体(父控件高度的5%) app:layout_textSizePercent="5%" --> <TextView android:id="@+id/test1" android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="left|top" android:background="#ff7ecc16" android:gravity="center" android:onClick="test1" android:text="百分比布局" app:layout_heightPercent="50%w" app:layout_widthPercent="50%h" app:layout_marginBottomPercent="10%sh" app:layout_marginEndPercent="10%sw" app:layout_marginLeftPercent="10%" app:layout_marginRightPercent="10%" app:layout_marginStartPercent="10%" app:layout_marginTopPercent="10%" app:layout_marginPercent="5%" app:layout_textSizePercent="5%" /></com.zhy.android.percent.support.PercentLinearLayout>
阅读全文
1 0
- 安卓 百分比布局
- 安卓百分比布局
- Android Percent Layout 安卓百分比布局
- 安卓百分比布局之RelativeLayout
- 安卓百分比布局的使用
- 安卓百分比布局增强版转换工具Px2Percent.jar
- 安卓设备适配终极杀器-谷歌百分比布局库的使用
- 安卓百分比布局---很好的解决屏幕适配问题
- 完美适配之安卓百分比布局使用,治好广大安卓程序员的头疼病
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 安卓学习--百分比适配
- [LeetCode] 125. Valid Palindrome
- LeetCode 506. Relative Ranks
- 自定义imageview中的canvas.drawBitmap方法
- JS-判断是否为微信扫码
- Android 自定义控件 优雅实现元素间的分割线 (支持3.0以下)
- 安卓百分比布局
- latex公式中的空格如何表示?
- 面试笔试准备和思考
- 线下活动【深圳】用Leangoo做Scrum敏捷开发实战课(免费)
- C++ 条件运算符(三目运算符)
- java解决手机等移动设备中照片上传至服务器方向不正确的问题
- java 中Date时间转换问题
- java算法之二分查找
- Struts2文件的上传的与下载