Created
February 8, 2017 10:53
-
-
Save silwar/ba2679baf5d5681796228e2fe9d01645 to your computer and use it in GitHub Desktop.
This is Android layout file to show how to divide views equally using Relativelayout. This better practice than using layout weights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<View | |
android:id="@+id/vertical_divider" | |
android:layout_width="0dp" | |
android:layout_height="match_parent" | |
android:layout_centerHorizontal="true" /> | |
<View | |
android:id="@+id/horizontal_divider" | |
android:layout_width="match_parent" | |
android:layout_height="0dp" | |
android:layout_centerVertical="true" /> | |
<LinearLayout | |
android:id="@+id/firstLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_above="@+id/horizontal_divider" | |
android:layout_toLeftOf="@id/vertical_divider" | |
android:background="#4285f4" | |
android:orientation="vertical" /> | |
<LinearLayout | |
android:id="@+id/secondLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_above="@+id/horizontal_divider" | |
android:layout_toRightOf="@id/vertical_divider" | |
android:background="#34A853" | |
android:orientation="vertical" /> | |
<LinearLayout | |
android:id="@+id/thirdLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_below="@id/horizontal_divider" | |
android:layout_toLeftOf="@id/vertical_divider" | |
android:background="#FBBC05" | |
android:orientation="vertical" /> | |
<LinearLayout | |
android:id="@+id/fourthLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_below="@id/horizontal_divider" | |
android:layout_toRightOf="@id/vertical_divider" | |
android:background="#EA4335" | |
android:orientation="vertical" /> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment