android 百分比布局percentFrameLayout,percentRelativeLayout的使用
2017-05-17 17:18
726 查看
这种布局方式是google新添加的一种布局,需要引入安卓的support兼容包,这个包大家都很清楚,一般android的新特效新功能都会在support包中。我们知道。在安卓的布局中,只有LinearLayout才支持设置权重weight来按比例划分控件的大小,其他布局都不支持这种方式,这就显得,有时候我们一些复杂点的布局搞起来就有点繁琐。为此,android引入了一种全新的布局方式来解决这个问题,---百分比布局,简单的理解就是在这个布局的控件可以设置百分比啦,很高大上有木有,,,,1.引入
compile'com.android.support:percent:24.2.1'
2.新建一个layout文件
<?xml version="1.0" encoding="utf-8"?> <android.support.percent.PercentFrameLayout xmlns: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"> <Button android:text="1" android:layout_gravity="left|top" app:layout_widthPercent="50%" app:layout_heightPercent="50%" /> <Button android:text="2" android:layout_gravity="right|top" app:layout_widthPercent="50%" app:layout_heightPercent="50%" /> <Button android:text="3" android:layout_gravity="left|bottom" app:layout_widthPercent="50%" app:layout_heightPercent="50%" /> <Button android:text="4" android:layout_gravity="right|bottom" app:layout_widthPercent="50%" app:layout_heightPercent="50%" /> </android.support.percent.PercentFrameLayout>我们可以看到,这里多了两个新属性---
app:layout_widthPercent="50%" app:layout_heightPercent="50%"
这就是指定我们的控件和父布局的百分之50.
上图
相关文章推荐
- 百分比布局PercentRelativeLayout - 简单使用
- Android百分比布局:PercentRelativeLayout
- Android百分比布局:PercentRelativeLayout
- Android百分比布局:PercentRelativeLayout
- 使用Java动态设置官方百分比布局PercentRelativeLayout的heightPerce
- android百分比布局PercentRelativeLayout
- Android Percent Layout 安卓百分比布局
- android xml布局文件中使用RelativeLayout,明明有这个id,却提示找不到---->解决办法
- Android 百分比布局库(percent-support-lib) 使用详解
- android 基本布局(RelativeLayout、TableLayout等)使用方法及各种属性
- 安卓第一行代码之百分比布局PercentFrameLayout/PercentRelativeLayout
- android PercentRelativeLayout 支持百分比来设置控件的宽高
- Android Percentlayout百分比布局
- Android中PercentRelativeLayout的使用详解
- 百分比布局(PercentFrameLayout和PercentRelativeLayout)
- android PercentRelativeLayout 支持百分比来设置控件的宽高
- Android RelativeLayout (相对布局)使用及介绍
- PercentRelativeLayout百分比布局
- android 相对布局RelativeLayout中的一些属性的使用和实例
- 百分比布局PercentRelativeLayout