美文网首页
Percent-Support-Extends 笔(百分比扩展框

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

作者: Demon鑫 | 来源:发表于2017-01-04 15:59 被阅读0次

    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.特殊属性
    • 50%w
      参考宽百分比
    • 15%h
      参考高百分比
    • 30%sw
      参考屏幕的宽
    • 30%sh
      参考屏幕的高
    3.全部属性
    • layout_heightPercent
    • layout_widthPercent
    • layout_marginBottomPercent
    • layout_marginEndPercent
    • layout_marginLeftPercent
    • layout_marginPercent
    • layout_marginRightPercent
    • layout_marginStartPercent
    • layout_marginTopPercent
    • layout_textSizePercent
    • layout_maxWidthPercent
    • layout_maxHeightPercent
    • layout_minWidthPercent
    • layout_minHeightPercent
    • layout_paddingPercent
    • layout_paddingTopPercent
    • layout_paddingBottomPercent
    • layout_paddingLeftPercent
    • layout_paddingRightPercent

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


    2017-1-4 15:57:49

    相关文章

      网友评论

          本文标题:Percent-Support-Extends 笔(百分比扩展框

          本文链接:https://www.haomeiwen.com/subject/mxoovttx.html