Skip to content

Commit

Permalink
[added]readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nitiwari-dev committed Sep 27, 2016
1 parent 941a043 commit 4244f99
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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](https://cloud.githubusercontent.com/assets/10304040/9567537/97e183f8-4f4c-11e5-8b34-f5f2411e67f5.png)
![percent_50_50](https://cloud.githubusercontent.com/assets/10304040/9567536/97dcc84a-4f4c-11e5-9406-4579e7ed4411.png)
![percent_tile2](https://cloud.githubusercontent.com/assets/10304040/9567539/97f413e2-4f4c-11e5-94a7-4aa59862fbac.png)

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 !!!.

```xml
<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 !!!
2 changes: 1 addition & 1 deletion local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Sep 27 23:23:05 IST 2016
#Wed Sep 28 01:00:00 IST 2016
ndk.dir=F\:\\setup\\android-studio-install-dir\\ndk-bundle
sdk.dir=F\:\\setup\\android-studio-install-dir

0 comments on commit 4244f99

Please sign in to comment.