Android百分比布局初探
标题:Android百分比布局初探
依赖库:——com.android.support:percent
实现原理:
- layout_widthPercent
- layout_heightPercent
- layout_marginPercent
- layout_marginLeftPercent
- layout_marginTopPercent
- layout_marginRightPercent
- layout_marginBottomPercent
- layout_marginStartPercent
- layout_marginEndPercent
官网代码:
1.
PercentFrameLayout
<android.support.percent.PercentFrameLayoutxmlns: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"/><ImageViewapp:layout_widthPercent="50%"app:layout_heightPercent="50%"app:layout_marginTopPercent="25%"app:layout_marginLeftPercent="25%"/></android.support.percent.PercentFrameLayout/>
2.PercentRelativeLayout
<android.support.percent.PercentRelativeLayoutxmlns: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"><Viewandroid: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%" /><Viewandroid: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%" /><Viewandroid: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%" /><Viewandroid: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>
效果:
Android百分比布局初探相关推荐
- android如何看百分比版本,【JAVA】Android百分比布局
开发我人生第一个app的时候,我在想有没有这么一种布局能适应任何手机的分辨率,今天让我们一起来看看Android 百分比布局PercentRelativeLayout. 使用这种布局首先我们要在gra ...
- Android百分比布局支持和垂直TextView
In this tutorial, we'll discuss and implement Android Percent Layout Support Library. Furthermore, w ...
- android 边距 百分比,Android百分比布局:PercentRelativeLayout
Android百分比布局:PercentRelativeLayout 在最新的Android support包中,增加了开发者期待的百分比布局PercentRelativeLayout和Perc ...
- Android 百分比布局
Android 百分比布局库(percent-support-lib) 解析与扩展 扩展库github地址
- Android 百分比布局(支持AndroidX)
Android 百分比布局 添加依赖 代码使用 添加依赖 implementation 'com.android.support:percent:25.2.0' 我的项目是AndroidX的,依然用这 ...
- android百分比布局失效,Android 百分比布局库【原创】
为了解决android手机适配问题,我们经常想如果可以按照百分比的方式进行界面布局,这样适配各种屏幕就简单多了吧!现在谷歌正式提供百分比布局支持库(android-support-percent-li ...
- Android 百分比布局、权重、隐藏TitleBar、引入自定义控件
一.LinearLayout权重 1.1.android:layout_weight="1" 两个控件设置为1可以将屏幕等分为两份,更改数值可以根据各自数值各占有屏幕的尺寸 ...
- Android 百分比布局+ScrollView
主要分为PercentRelativeLayout,和 PercentFrameLayout PercentRelativeLayout 一.添加依赖 compile 'com.android.sup ...
- android百分比布局适配,安卓屏幕适配-百分比布局
屏幕适配-百分比布局 原理:以父容器尺寸作为参考,在View的加载过程,根据当前父容器实际尺寸换算出目标尺寸,在作用在View上. 百分比布局实际是对容器的一中扩展,扩展的是宽高等比例的设置. 1.自 ...
最新文章
- 简单的 HTTP 调用,为什么时延这么大?
- win7光盘修复计算机在哪,win7如何创建系统还原及系统修复光盘功能应用
- linux top交叉编译_ARM Linux交叉编译工具链的制作
- 在C++中可以用3种方法访问一个字符串
- excel实战应用案例100讲(十二)-用Excel做一个自动抽奖器
- 漫步数学分析九——级数
- mysql启动失败2005_数据库2005服务启动不了
- HTML示例06---水平线
- cesium模型不遮挡点线面_VueCLI3.0干货系列之集成Cesium三维地球框架
- 计算机单片机实训报告,单片机实训报告范文
- Django连接MySQL8.0报错django.db.utils.OperationalError: (1045, “Access denied for user ‘16066‘@‘localhos
- 图10——判断顶点u和顶点v是否存在简单路径
- adjacency list(邻接表)神物
- 完全平方数(C语言,调用函数)
- 岁月温柔-2 又住院了,祈祷早日康复
- 用UNetbootin 制作Linux 安装U盘
- 计算机老师的寄 语,计算机专业老师毕业赠言
- 解析!如何从手机网站直接跳转到微信添加好友界面
- 3388=24及24点游戏的穷举算法
- 解决Win10下Fliqlo无法显示,显示一个Fi的图标
热门文章
- php 编译错误,PHP 编译错误及解决办法
- 自定义request_Spring Security 自定义登录认证(二)
- 将数据导入到mysql_06955.10.2如何将CM的外部PostgreSQL数据库迁移至MySQL服务
- 不需要网络的调频收音机_测试工程师真的不需要懂网络知识么?
- php 信号量 关闭,PHP信号量基本用法实例详解
- linux怎么进入bios查看mac地址,详细教您查看本机mac地址
- 机器学习之--梯度下降和最小二乘法算线性回归
- BZOJ4589: Hard Nim(FWT 快速幂)
- 递归方法:对于树形结构的表,根据当前数据获取无限极的父级名称
- jQuery-处理class属性