Percent-Support-Extends 笔(百分比扩展框

2017-01-04  本文已影响0人  Demon鑫

Percent-Support框架扩展

框架作者地址
整理了一下以后备用

0.添加依赖
compile 'com.zhy:percent-support-extends:1.1.1'
1.Percent-Support使用
PercentRelativeLayout(相对布局百分比)
<com.zhy.android.percent.support.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%" />

</com.zhy.android.percent.support.PercentRelativeLayout>
PercentFrameLayout(帧布局百分比)
<com.zhy.android.percent.support.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">
    <!-- ... XML CODE -->

</com.zhy.android.percent.support.PercentFrameLayout>
PercentLinearLayout(线性布局百分比)
<com.zhy.android.percent.support.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">

    <TextView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="center"
        android:text="width:60%,height:5%,ts:3%"
        android:textColor="#000000"
        app:layout_heightPercent="10%w"
        app:layout_textSizePercent="4%"
        app:layout_widthPercent="60%h"/>

</com.zhy.android.percent.support.PercentLinearLayout>
textView、button、editText(字体大小百分比)
app:layout_textSizePercent="3%h"
2.特殊属性
3.全部属性

对于值可以取:10%w , 10%h , 10% , 10%sw , 10%sh


2017-1-4 15:57:49

上一篇下一篇

猜你喜欢

热点阅读