Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
README.md
build.gradle
gradle.properties
local.properties
settings.gradle

README.md

android-percent-layout-sample

This demo displays how to use android support percent library with the help of different layouts as examples.It replaces our tranditional way of using layout_weight of LinearLayout in order to access out screen area for different widgets.

Really awesome!!!

percent_init percent_50_50 percent_tile2

Steps:

  1. Add below into build.gradle

    compile 'com.android.support:percent:23.0.0'

  2. Add any one of this as parent layout.

    <android.support.percent.PercentRelativeLayout> or <android.support.percent.PercentFrameLayout>

  3. Finally use layout_heightPercent and layout_widthPercent properties. Thats it !!!.

<android.support.percent.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">
    <TextView
        android:id="@+id/fifty_huntv"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#ff7acfff"
        android:text="20% - 50%"
        android:textColor="@android:color/white"
        app:layout_heightPercent="20%"
        app:layout_widthPercent="50%" />
    <TextView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_toRightOf="@id/fifty_huntv"
        android:background="#ffff5566"
        android:text="80%-50%"
        app:layout_heightPercent="80%"
        app:layout_widthPercent="50%"
        />

</android.support.percent.PercentRelativeLayout>

Bingo we are done !!!