Skip to content

Instantly share code, notes, and snippets.

@kalvian1060
Created May 13, 2017 04:25
Show Gist options
  • Save kalvian1060/ae85ef108c5e274e1ed8c9b66029f2d6 to your computer and use it in GitHub Desktop.
Save kalvian1060/ae85ef108c5e274e1ed8c9b66029f2d6 to your computer and use it in GitHub Desktop.
Penggunaan Relative Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dce0e8">
<ImageView
android:id="@+id/icon_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:src="@drawable/chat" />
<TextView
android:id="@+id/title_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/icon_image"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="Chat"
android:textColor="#2dbbef"
android:textSize="30sp" />
<TextView
android:id="@+id/desc_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title_chat"
android:gravity="center"
android:text="Simple Mobile Chat"
android:textColor="#2dbbef"
android:textSize="20sp" />
<RelativeLayout
android:id="@+id/form_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/desc_title"
android:layout_margin="10dp"
android:background="@android:color/white"
android:padding="16dp">
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="Username"
android:padding="10dp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/username"
android:layout_marginTop="5dp"
android:hint="Password"
android:inputType="textPassword"
android:padding="10dp" />
<Button
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password"
android:layout_marginTop="10dp"
android:background="#2dbbef"
android:gravity="center"
android:text="LOGIN"
android:textColor="@android:color/white" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@+id/btnLogin"
android:layout_marginTop="10dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Remember Password" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="Forgot Password"
android:textStyle="italic" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp">
<TextView
android:id="@+id/title_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Belum Punya Akun?"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/title_footer"
android:text="Daftar"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment