Android Percent Layouts

build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:percent:25.3.1'
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="ir.mhdr.a081.MainActivity">

    <View android:background="@color/colorPrimary"
        app:layout_heightPercent="50%"
        app:layout_marginLeftPercent="25%"
        app:layout_marginTopPercent="25%"
        app:layout_widthPercent="50%"
        android:id="@+id/viewColor">

    </View>

    <android.support.percent.PercentFrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/viewColor"
        android:layout_centerInParent="true"
        android:layout_alignParentBottom="true">

        <View
            android:layout_gravity="center"
            android:background="@color/colorAccent"
            app:layout_heightPercent="30%"
            app:layout_widthPercent="50%" />
    </android.support.percent.PercentFrameLayout>

</android.support.percent.PercentRelativeLayout>

References
https://github.com/mhdr/AndroidSamples/tree/master/081
https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html
https://developer.android.com/reference/android/support/percent/PercentFrameLayout.html
https://developer.android.com/topic/libraries/support-library/packages.html