# android-percent-support-extend
>a extends lib for android-percent-support
>
>对于android-percent-support的扩展库。
contains project for android studio and eclipse .
上面包含as和ec的项目,自行导入。
* support for android-percent-support's orgin abilities
* 支持该库的原有功能,且用法不变
* add PercentLinearLayout
* 添加了PercentLinearLayout
* support for all attrs use fraction value based on specified width or height.
* 支持百分比指定特定的参考值,比如宽度或者高度。
* support for use app:layout_textSizePercent for textSize of textView
>such as `app:layout_heightPercent="50%w"`,
`app:layout_marginPercent="15%w"`,
`app:layout_marginBottomPercent="20%h"`.
* 支持通过app:layout_textSizePercent设置textView的textSize
we not only support fraction value , but also we support use fraction value based on width or height , such as 10% , 10%w , 10%h 。
不仅支持百分比设置布局的值,并且可以指定百分比参考的是宽度还是高度。如果不指定宽度和高度,则默认和原本的库效果一致。
Why I Why extend this library ?
为什么要扩展你这个库?
Because , there are some views in my layout are square , such as FloatingActionButton , i wanna its' width and height both are 15% of width , since I add this ability , so that I can define as below :
因为,在我的布局中有部分View是正方形的大小,比如FloatingActionButton,我希望它的高度和宽度都是宽度的15%,因此我添加了该功能,以至于我可以按照下面的写法编写:
```
<android.support.percent.PercentFrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:background="#ffcc5ec7"
app:layout_heightPercent="50%w"
app:layout_widthPercent="50%w">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#ff7ecc16"
android:gravity="center"
android:text="margin 15% of w"
app:layout_marginPercent="15%w"
/>
</android.support.percent.PercentFrameLayout>
```
also , I wanna View has same margin for all direction , if we use 5% , leftMargin and rightMagin are width'5% , topMargin and bottonMargin are height'5% . In this library , you can use : `app:layout_marginPercent="5%w"`.
有时候,我希望View的margin在4个方向的值是一致的,如果使用原本的库,5%会造成横向与纵向的值不一致。而根据添加的功能,你可以使用:`app:layout_marginPercent="5%w"`。
## How to use
对于Android Studio,只需要添加:
```xml
compile 'com.zhy:percent-support-extends:1.0'
```
就可以使用,所有的类名为,源码的话,大家直接下载这个库即可:
```java
com.zhy.android.percent.support.PercentLinearLayout
com.zhy.android.percent.support.PercentRelativeLayout
com.zhy.android.percent.support.PercentFrameLayout
```
##Some Example
<img src="sc_01.png" width="320px"/>
xml:
```xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentLinearLayout
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"
android:orientation="vertical">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#ff44aacc"
android:text="width:60%,height:5%"
android:textColor="#ffffff"
app:layout_heightPercent="5%"
app:layout_marginBottomPercent="5%"
app:layout_widthPercent="60%"/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#ff4400cc"
android:gravity="center"
android:textColor="#ffffff"
android:text="width:70%,height:10%"
app:layout_heightPercent="10%"
app:layout_marginBottomPercent="5%"
app:layout_widthPercent="70%"/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#ff44aacc"
android:gravity="center"
android:text="width:80%,height:15%"
android:textColor="#ffffff"
app:layout_heightPercent="15%"
app:layout_marginBottomPercent="5%"
app:layout_widthPercent="80%"/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#ff4400cc"
android:gravity="center"
android:text="width:90%,height:5%"
android:textColor="#ffffff"
app:layout_heightPercent="20%"
app:layout_marginBottomPercent="5%"
app:layout_widthPercent="90%"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#ff44aacc"
android:gravity="center"
android:text="width:100%,height:25%"
android:textColor="#ffffff"
app:layout_heightPercent="25%"
app:layout_marginBottomPercent="5%"
/>
</android.support.percent.PercentLinearLayout>
```
<img src="sc_02.png" width="320px"/>
xml:
```xml
<?xml version="1.0" encoding="utf-8"?>
<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"
android:orientation="vertical">
<android.support.percent.PercentFrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:background="#ff44aacc"
app:layout_heightPercent="50%w"
app:layout_widthPercent="50%w">
<android.support.percent.PercentFrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:background="#ffcc5ec7"
app:layout_heightPercent="50%w"
app:layout_widthPercent="50%w">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#ff7ecc16"
android:gravity="center"
android:text="margin 15% of w"
app:layout_marginPercent="15%w"
/>
</android.support.percent.PercentFrameLayout>
</android.support.percent.PercentFrameLayout>
<TextView android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="bottom|right"
android:background="#44ff0000"
android:gravity="center"
android:text="15%w,15%w"
app:layout_heightPercent="15%w"
app:layout_marginPercent="5%w"
app:layout_widthPercent="15%w"/>
</android.support.percent.PercentFrameLayout>
```
<img src="sc_03.png" width="320px"/>
xml:
```xml
<?xml version="1.0" encoding="utf-8"?>
<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">
<TextView
android:id="@+id/id_test"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="left|top"
android:background="#44ff0000"
android:gravity="center"
android:onClick="test1"
android:text="width:30%,height:20%"
app:layout_heightPercent="20%"
app:layout_widthPercent="30%"/>
<TextV
没有合适的资源?快使用搜索试试~ 我知道了~
Android屏幕适配(按百分比)
共80个文件
xml:37个
png:16个
java:13个
3星 · 超过75%的资源 需积分: 49 219 下载量 139 浏览量
2015-07-03
18:33:44
上传
评论
收藏 404KB ZIP 举报
温馨提示
在GidHub上看到的关于Android品目适配,是按照屏幕百分比适配的哦。。。里面有Eclipse和Studio的Demo并附带效果图
资源推荐
资源详情
资源评论
收起资源包目录
android-percent-support-extend-master.zip (80个子文件)
android-percent-support-extend-master
.gitignore 300B
eclipse
Android-support-screen-extends
AndroidManifest.xml 939B
res
mipmap-xhdpi
ic_launcher.png 5KB
mipmap-mdpi
ic_launcher.png 2KB
layout
view3.xml 2KB
view2.xml 1KB
activity_category.xml 278B
view1.xml 2KB
item_category.xml 547B
activity_item.xml 775B
view4.xml 2KB
activity_main.xml 915B
view5.xml 2KB
values-w820dp
dimens.xml 358B
mipmap-xxhdpi
ic_launcher.png 8KB
menu
menu_main.xml 392B
menu_item.xml 425B
main.xml 433B
drawable-mdpi
ic_launcher.png 4KB
mipmap-hdpi
ic_launcher.png 3KB
values-v11
styles.xml 321B
drawable-hdpi
tangyan.jpeg 24KB
ic_launcher.png 7KB
drawable-xhdpi
ic_launcher.png 12KB
values-v14
styles.xml 378B
drawable-xxhdpi
ic_launcher.png 24KB
values
strings.xml 254B
attrs.xml 705B
dimens.xml 211B
styles.xml 194B
src
com
zhy
android_percent_support
MainActivity.java 3KB
ItemActivity.java 1KB
android
support
percent
PercentRelativeLayout.java 5KB
PercentLinearLayout.java 2KB
PercentFrameLayout.java 5KB
PercentLayoutHelper.java 25KB
proguard-project.txt 781B
.classpath 466B
project.properties 607B
ic_launcher-web.png 50KB
.project 833B
studio
android-percent-support
.gitignore 7B
build.gradle 599B
src
androidTest
java
com
imooc
android_percent_support
ApplicationTest.java 368B
main
AndroidManifest.xml 836B
res
mipmap-xhdpi
ic_launcher.png 5KB
mipmap-mdpi
ic_launcher.png 2KB
layout
view3.xml 2KB
view2.xml 1KB
activity_category.xml 278B
view1.xml 2KB
item_category.xml 547B
activity_item.xml 777B
view4.xml 2KB
activity_main.xml 915B
view5.xml 2KB
values-w820dp
dimens.xml 358B
mipmap-xxhdpi
ic_launcher.png 8KB
menu
menu_main.xml 392B
menu_item.xml 425B
mipmap-hdpi
ic_launcher.png 3KB
drawable-hdpi
tangyan.jpeg 24KB
values
strings.xml 254B
attrs.xml 767B
dimens.xml 211B
styles.xml 194B
java
com
imooc
android_percent_support
MainActivity.java 3KB
ItemActivity.java 1KB
android
support
percent
PercentRelativeLayout.java 5KB
PercentLinearLayout.java 2KB
PercentFrameLayout.java 5KB
PercentLayoutHelper.java 26KB
android-percent-support.iml 7KB
proguard-rules.pro 672B
sc_01.png 97KB
LICENSE 11KB
sc_03.png 105KB
README-orgin.md 3KB
sc_02.png 59KB
README.md 12KB
共 80 条
- 1
资源评论
- lx快乐就好2015-11-09对新手没有什么用处
- 彭生奇2016-07-05非常不错,值得借鉴。
- hm_super_man2015-12-15是第三方扩展版的,想要原版。。。
Liundev
- 粉丝: 12
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功