Cara penggunaan Relative Layout pada Android
Nama:Fachrizal Ali
Kelas:XI RPL 2
Mapel: PBO
Dalam tugas PBO sekarang ini,kita akan mempelajari bagaimana cara penggunaan Relative Layout di Android Studio.Relative Layout berfungsi sebagai tata letak yang ada di Android, layout sangat berguna dalam tata letak,dimana layout berfungsi sebagai posisi dari icon atau peletakan tulisan.
Relative layout dapat digunakan di dalam layout lain, contoh:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android>
<RelativeLayout>
<RelativeLayout/>
<LinearLayout/>
Berikut Codingan nya
<?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"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:layout_alignParentTop="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:layout_alignParentRight="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:layout_centerHorizontal="true"
android:layout_marginTop="325dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:layout_alignParentBottom="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Komentar
Posting Komentar