安卓学习--百分比适配
来源:互联网 发布:淘宝企业店铺公示地址 编辑:程序博客网 时间:2024/05/18 16:56
博客:http://blog.csdn.net/muyang_ren
一、修改MyApplication\app目录下的build.gradle
添加 compile'com.android.support:percent:23.1.1'
<pre name="code" class="html">dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:percent:23.1.1'}
版本号可能会不一样
二、XML布局修改
1、RelativeLayout 修改为 android.support.percent.PercentRelativeLayout
2、添加 xmlns:app="http://schemas.android.com/apk/res-auto" 属性
3、百分比属性 app:layout_heightPercent="7%"
- layout_widthPercent
设置控件宽度为父容器的宽的百分比
- layout_heightPercent
设置控件高度为父容器的高的百分比
- layout_marginPercent
- layout_marginLeftPercent
设置控件与左边控件的距离为父容器的宽度的百分比
- layout_marginTopPercent
设置控件与上方控件的距离为父容器的高度的百分比
- layout_marginRightPercent
设置控件与右边控件的距离为父容器的宽度的百分比
- layout_marginBottomPercent
设置控件与下方控件的距离为父容器的高度的百分比
- layout_marginStartPercent
与上面的说明类似
- layout_marginEndPercent
与上面的说明类似
<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.lianghuiyong.myapplication.MainActivity"> <RelativeLayout android:id="@+id/header_layout" android:layout_width="fill_parent" android:layout_alignParentTop="true" app:layout_heightPercent="7%" android:background="@color/MyAPP_header_color"> <ImageButton android:id="@+id/header_setting" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/header_setting" android:layout_marginLeft="18dp" android:layout_centerVertical="true" android:contentDescription="imagebutton" /><?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.lianghuiyong.myapplication.MainActivity"> <RelativeLayout android:id="@+id/header_layout" android:layout_width="fill_parent" android:layout_alignParentTop="true" app:layout_heightPercent="7%" android:background="@color/MyAPP_header_color"> <ImageButton android:id="@+id/header_setting" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/header_setting" android:layout_marginLeft="18dp" android:layout_centerVertical="true" android:contentDescription="imagebutton" />
0 0
- 安卓学习--百分比适配
- 安卓 百分比布局
- 安卓百分比布局
- 安卓设备适配终极杀器-谷歌百分比布局库的使用
- 安卓百分比布局---很好的解决屏幕适配问题
- 完美适配之安卓百分比布局使用,治好广大安卓程序员的头疼病
- android百分比布局学习,适配相关
- Android Percent Layout 安卓百分比布局
- 安卓百分比布局之RelativeLayout
- 安卓百分比布局的使用
- android 百分比适配
- Android百分比适配
- 百分比适配举例
- 百分比适配
- Android百分比适配
- 如何在安卓4.4状态栏开启电池剩余百分比
- 安卓百分比布局增强版转换工具Px2Percent.jar
- 安卓7.0上在状态栏上加电池百分比
- Codeforces Educational Codeforces Round 2 B. Queries about less or equal elements
- 027.迭代器 Iterator
- hpuoj 1716: 感恩节KK专场——考试来了 【水题】【校赛】
- Codevs_P2711 数的划分(DP)
- 使用JDBC操作时间的注意点
- 安卓学习--百分比适配
- (未完)逆波兰计算器功能分层:
- 发布iOS企业分发(二)(iOS开发环境配置)
- 相机曝光与增益
- hdoj--2516--取石子游戏(博弈)
- ubuntu默认开启numlock
- Java集合中HashMap的实现原理
- OpenJudge_P8787 数的划分(DP)
- 安卓消息推送解决方案