百分比布局的使用
来源:互联网 发布:智能视频分析软件 编辑:程序博客网 时间:2024/05/21 01:55
百分比布局可以让Relativelayout 和FrameLayout 来实现让;两个按钮按比例布局的效果。
百分比布局是为FrameLayout和RelativeLayout进行了功能的扩展,
提供了PercentRelativeLayout 和 PercentFramelayout这两个全新的布局。
百分比布局属于新增布局,其定义在support库当中,我们在引用的时候需要在项目的build.gradle中添加依赖库:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:percent:24.2.1'}
布局文件:<?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentRelativeLayout 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:id="@+id/bt01" android:layout_alignParentLeft="true" app:layout_widthPercent="60%" app:layout_heightPercent="50%"/> <Button android:id="@+id/bt02" android:layout_alignParentRight="true" app:layout_widthPercent="38%" app:layout_heightPercent="50%"/> <Button android:id="@+id/bt03" android:layout_alignParentLeft="true" android:layout_below="@+id/bt01" app:layout_widthPercent="60%" app:layout_heightPercent="50%"/> <Button android:id="@+id/bt04" android:layout_alignParentRight="true" android:layout_below="@+id/bt01" app:layout_widthPercent="38%" app:layout_heightPercent="50%"/></android.support.percent.PercentRelativeLayout>
这个错误是Android sdudio中内置布局检查机制引起的,这个错误不会影响程序的运行,我们直接忽视就可以了
运行程序,效果如图:
0 0
- 百分比布局的使用
- 百分比布局的使用
- 百分比布局的使用
- Android百分比布局的使用
- Android 百分比布局库的使用
- android 百分比布局percentFrameLayout,percentRelativeLayout的使用
- 安卓百分比布局的使用
- CSS 使用百分比布局
- 在WPF中使用百分比的布局方式
- Css表格布局的百分比
- 百分比布局支持的属性
- 关于CSS的百分比布局
- 百分比布局的基本用法
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 使用CXF开发WebService服务器端接口
- 忘记oracle的sys用户密码怎么修改
- java内存模型读书笔记
- GreenDao自带异步操作类简析
- Boolean数据类型转换
- 百分比布局的使用
- 内存分析工具MAT的使用
- Spring Cloud构建微服务架构(四)分布式配置中心(续)
- c#委托和lambda表达式(一)
- Android判断网络是否连接,跳转到设置页面以及判断连接的是什么网络
- php表单验证
- 学习软件是否一定要去培训学院
- 使用CXF开发WebService客户端
- 闲谈自定义控件源码-view layout draw