Skip to content

Instantly share code, notes, and snippets.

@ariefannur
Created March 21, 2018 03:56
Show Gist options
  • Save ariefannur/f25ac1226cfe7fe80643420cec69fb22 to your computer and use it in GitHub Desktop.
Save ariefannur/f25ac1226cfe7fe80643420cec69fb22 to your computer and use it in GitHub Desktop.
simple layout relative and linear layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:padding="16dp"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/lay1"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@color/colorPrimary">
<ImageView
android:id="@+id/img1"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="@color/white"
android:layout_centerInParent="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini adalah text 1"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:layout_below="@+id/img1"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lay1"
android:orientation="horizontal"
android:layout_marginTop="16dp"
android:weightSum="3">
<LinearLayout
android:id="@+id/img2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text A"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text B"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/img3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text A"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text B"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/img4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text A"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ini Text B"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment