Android百分比布局:PercentFrameLayout

简介: Android百分比布局:PercentFrameLayout在之前一篇文章我写了Android的百分比占布局:PercentRelativeLayout。


Android百分比布局:PercentFrameLayout

在之前一篇文章我写了Android的百分比占布局:PercentRelativeLayout。(《Android百分比布局:PercentRelativeLayout》文章链接地址:http://blog.csdn.net/zhangphil/article/details/49532493
Android新增的百分比占布局有两个PercentFrameLayout和PercentRelativeLayout。本篇介绍PercentFrameLayout。
同样,PercentFrameLayout也有和PercentRelativeLayout类似的以下一些属性:
layout_marginLeftPercent
layout_marginTopPercent
layout_marginRightPercent
layout_marginBottomPercent
layout_marginStartPercent
layout_marginEndPercent
layout_aspectRatio

使用方法和前一篇介绍的PercentRelativeLayout类似。在类层次结构上,PercentFrameLayout继承自FrameLayout。既然使用百分比占布局,其实在一定程度上可以不用再像以往那样指定view的宽高或者match_parent、wrap_content诸如此类。比如:

<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" >

    <TextView
        app:layout_heightPercent="90%"
        app:layout_widthPercent="90%"
        android:background="#c62828" />

    <TextView
        app:layout_heightPercent="80%"
        app:layout_widthPercent="80%"
        android:background="#e53935" />

    <TextView
        app:layout_heightPercent="70%"
        app:layout_widthPercent="70%"
        android:background="#f44336" />

    <TextView
        app:layout_heightPercent="60%"
        app:layout_widthPercent="60%"
        android:background="#ef5350" />

    <TextView
        app:layout_heightPercent="50%"
        app:layout_widthPercent="50%"
        android:background="#e57373" />

</android.support.percent.PercentFrameLayout>


运行结果如图所示:


相关文章
|
Android开发 数据格式 XML
Android NumberProgressBar:动态移动显示百分比进度的进度条
 Android NumberProgressBar:动态移动显示百分比进度的进度条 NumberProgressBar是github上一个开源项目,其项目主页是:https://github.com/daimajia/NumberProgressBar NumberProgressBar特点是当进度条在前进时候,显示出来的百分比进度数字随进度条实时显示出来,如图: 这种特点在实现一些比如下载、加载功能模块时候比较有用。
1837 0
|
Android开发 数据格式 XML
Android屏幕适配之百分比布局
为什么使用百分比布局 由于Android系统的碎片化发展导致了市面上多种分辨率、多种屏幕密度共存,这对我们的屏幕适配增加了不少的难度,在布局方面我们都知道可以通过LinearLayout的layout_weight属性来进行适配,但是在某些情况下我们要向用这种方法进行适配就必须进行多层布局嵌套,而这则会导致布局文件复杂,增加渲染层次,致使性能下降。
1005 0
|
Android开发 iOS开发
Android/iOS及设计中ARGB颜色值百分比透明度换算
Android/iOS及设计中ARGB颜色值百分比透明度换算 设计上经常要求对一个颜色值进行一定百分比的透明度,比如给定一个颜色0xFF0000FF(蓝色)要求80%透明,该如何处理呢?80%透明的蓝色值是多少呢?常见的颜色是RGB表示的,就比如上面的蓝色0xFF0000FF,这个颜色值是16进制表示的,其中0x后面接着的两个16进制数字‘FF’就是ARGB中的‘A’,即alpha。
2863 0
|
Android开发
我的Android进阶之旅------&gt;Android颜色值(#AARRGGBB)透明度百分比和十六进制对应关系以及计算方法
我的Android进阶之旅——>Android颜色值(RGB)所支持的四种常见形式 透明度百分比和十六进制对应关系表格 透明度 十六进制 100% FF 99% FC 98% FA 97% F7 96% ...
1105 0
|
Android开发 容器 开发工具
Android 百分比布局库(percent-support-lib)
Google开始支持百分比的方式布局了已经大半年了吧(7个月??)https://github.com/JulienGenoud/android-percent-support-lib-sample 这个项目阐述了百分比布局方式,方法。
837 0
|
Android开发 数据格式 XML
Android百分比布局:PercentRelativeLayout
 Android百分比布局:PercentRelativeLayout 在最新的Android support包中,增加了开发者期待的百分比布局PercentRelativeLayout和PercentFrameLayout,不过,Android官方是以support包的支持形式出现。
1027 0
|
Android开发 容器
Android百分比布局初探
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.
969 0