Skip to content

Instantly share code, notes, and snippets.

@bratawisnu
Created August 18, 2018 14:45
Show Gist options
  • Save bratawisnu/dec36e66d4f710feacfd6bba2497f72a to your computer and use it in GitHub Desktop.
Save bratawisnu/dec36e66d4f710feacfd6bba2497f72a to your computer and use it in GitHub Desktop.
Berikut contoh pembuatan Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#ef9842"
android:padding="10dp"
android:src="@drawable/img_logo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#e6d6d380">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="1"
android:textColor="#fff"
android:textSize="50sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#e6d6d380">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="2"
android:textColor="#fff"
android:textSize="50sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#e6d6d380">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="3"
android:textColor="#fff"
android:textSize="50sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#e6d6d380">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="4"
android:textColor="#fff"
android:textSize="50sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
<Button
android:id="@+id/btnAction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#ce9a2b"
android:text="Button"
android:textColor="#fff" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment