Android官-按百分比来设置控件的宽高
2015-09-06 11:32
288 查看
我做了一个新的百分比支持库的示例。
需要引用 包:'com.android.support:percent:22.2.0'
[align=left]它将很快就会记录在android开发网站,它只是一个概念验证[/align]
[align=left]你可以在这里检查官方文档引用[/align]
[align=left]这个库提供基于百分比的布局,同时水平和垂直。[/align]
[align=left]简单的结果[/align]
[align=left]复杂的结果[/align]
[b]如何使用:[/b]
[align=left]就百分比支持库添加到您的项目[/align]
dependencies { compile 'com.android.support:percent:22.2.0' }
PercentRelativeLayout
<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"> <View android:id="@+id/top_left" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:background="#ff44aacc" app:layout_heightPercent="20%" app:layout_widthPercent="70%" /> <View android:id="@+id/top_right" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/top_left" android:background="#ffe40000" app:layout_heightPercent="20%" app:layout_widthPercent="30%" /> <View android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@+id/top_left" android:background="#ff00ff22" app:layout_heightPercent="80%" /> </android.support.percent.PercentRelativeLayout>
PercentFrameLayout
<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"> <!-- ... XML CODE --> </android.support.percent.PercentFrameLayout>
相关文章推荐
- android 布局之滑动探究 scrollTo 和 scrollBy 方法使用说明
- android中的Filter接口简介
- flash air快速构建android demo测试程序
- Android 界面滑动实现---Scroller类 从源码和开发文档中学习(让你的布局动起来)
- Android -- 使用UncaughtExceptionHandler捕获全局异常
- Android 仿 窗帘效果 和 登录界面拖动效果 (Scroller类的应用) 附 2个DEMO及源码
- android:screenOrientation属性详解
- Android NDK开发学习(三)
- android实现图片反转效果
- android中内容提供者者ContentProvider的简单应用
- 新建 Android 测试工程
- android中隐藏与显示软键盘及不自动弹出键盘及软键盘将布局顶上去的实现方法
- Java垃圾收集和Android垃圾收集
- Android开发资料
- Android即时智能聊天软件
- Android xml 布局
- Android中ViewPager在底部生成小圆点
- Android中Acition和Category常量表
- android中使用自定义View让图片像画卷一样被展开显示
- 初次学习Android时项目的创建