College[MobileProgramming] Practice Simple UI

--

Oke kali ini kita akan membuat UI simple dalam android tanpa memasukkan logic kedalam aplikasi yang kita buat, berikut adalah contoh UI yang akan kita buat.

Seperti biasa kita harus membuat project baru aplikasi android dan pilih empty activity.

Buat semuanya default saja, lalu klik finish. Lalu masukkan kode berikut dalam main_activity.xml

<?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:background="@color/teal_200"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="20dp">

<TextView
android:id="@+id/tv_panjang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Panjang"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/tv_lebar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lebar"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/tv_tinggi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tinggi"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_gravity="center_horizontal"
android:text="Hitung tersimpan"/>

<Button
android:id="@+id/btn_keseluruhan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_gravity="center_horizontal"
android:text="Hitung tersimpan"/>

<TextView
android:id="@+id/tv_hasil"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tinggi"
android:textStyle="bold"
android:textAlignment="center"/>

</LinearLayout>

Setelah selesai menulis kode diatas, kita dapat langsung running di Android Studio, lalu berikut adalah hasilnya.

Sekian dan terima kasih.

--

--