Android百分比适配
来源:互联网 发布:python ggplot风格 编辑:程序博客网 时间:2024/05/23 00:27
Android提供了新的适配方案,通过百分比分配控件的大小
具体的实现过程如下:
1.在Android Studio中使用的时候需要在gradle中导入 compile ‘com.android.support:percent:22.2.0’
2.总共提供了两种适配布局:PercentRelativeLayout、PercentFrameLayout
3.提供的属性:
layout_widthPercent, layout_heightPercent, layout_marginPercent, layout_marginLeftPercent, layout_marginTopPercent, layout_marginRightPercent, layout_marginBottomPercent, layout_marginStartPercent, layout_marginEndPercent
这里就不多解释具体的属性
4.使用
布局:
<?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentRelativeLayoutxmlns: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.fiberhome.firstconclusion.MainActivity"><com.fiberhome.firstconclusion.MyTextViewandroid:id="@+id/mtv"android:layout_width="10dp"android:layout_height="0dp"app:layout_widthPercent="30%"app:layout_heightPercent="20%"app:Text="width 30%;height 20%"app:TextColor="@android:color/holo_orange_dark"android:layout_alignParentLeft="true"app:layout_marginPercent="2%"app:TextSize="10sp"/><com.fiberhome.firstconclusion.MyTextViewandroid:id="@+id/mtv1"android:layout_width="0dp"android:layout_height="0dp"app:layout_widthPercent="60%"app:layout_heightPercent="20%"app:Text="width 60%;height 20%"android:layout_alignParentRight="true"app:layout_marginPercent="2%"app:TextColor="@android:color/holo_red_dark"app:TextSize="15sp"/><com.fiberhome.firstconclusion.MyTextViewandroid:id="@+id/mtv2"android:layout_width="match_parent"android:layout_height="0dp"android:background="@android:color/holo_blue_dark"app:layout_heightPercent="70%"app:Text="width 100%;height 70%"android:layout_alignParentBottom="true"app:layout_marginPercent="2%"app:TextColor="@android:color/holo_blue_dark"app:TextSize="15sp"/></android.support.percent.PercentRelativeLayout>
效果图如下所示:
阅读全文
0 0
- android 百分比适配
- Android百分比适配
- Android百分比适配
- Android屏幕适配,百分比布局
- Android屏幕适配,百分比布局
- android百分比布局学习,适配相关
- 关于android中的百分比适配
- android支持百分比的屏幕适配
- Android适配之百分比布局
- Android界面百分比适配-PercentRelativeLayout
- 百分比适配举例
- 百分比适配
- Android 百分比适配,轻松解决适配问题
- Android DraerLayout 抽屉百分比适配屏幕宽度
- Android百分比布局解决屏幕适配问题
- Android 控件屏幕适配之百分比布局
- Android 屏幕适配方案(百分比)
- Android 屏幕适配方案(百分比)
- Unresolved inclusion: <jni.h>
- 解决Servlet中,中文乱码的问题
- 构造方法
- React受控组件与非受控组件
- 2017年浙江中医药大学大学生程序设计竞赛(重现赛)-H剪纸
- Android百分比适配
- iOS中Storyboard和class内连线问题
- 按钮控制EditText删除单个字符
- rhel6和rhel7日常使用差别
- 工业网络安全:TRITON恶意软件简单分析与防护方案
- 标识符
- python3 函数
- win10 openmeetings-4.0.1 配置
- 用profile协助程序性能优化