PercentLayout是百分比控件, 使用百分比属性创建控件. 除了常用的百分比, 也可以使用固定比例进行布局(aspect ratio). Percent相关Layout包括: PercentFrameLayout \ PercentRelativeLayout.
Gradle依赖
compile ‘com.android.support:percent:23.1.0‘
Layout布局, 提供宽度和比例, 自动适配高度.
    <android.support.percent.PercentRelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/main_text">
        <ImageView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="#FF1493"
            app:layout_aspectRatio="@fraction/header_aspectRatio"
            app:layout_widthPercent="50%"/>
    </android.support.percent.PercentRelativeLayout>
比例的资源文件, fractions.xml.
<resources>
    <item name="header_aspectRatio" type="fraction">178%</item>
</resources>
178%的含义是16:9.
OK, 可以通过比例, 更好的设置百分比控件.
原文:http://blog.csdn.net/caroline_wendy/article/details/50107829