Gambar 1. Floating button android |
Sudah lama tidak membuat tutorial Android, padahal dari tahun-ketahun banyak perubahan pada android dari sisi UI/UX (User Interface/User Experience) dan fungsi-fungsi didalamnya. Tutorial kali ini membahas bagaimana cara membuat floating button menggunakan android studio.
layout/activity_main.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:orientation="vertical"> </LinearLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" app:backgroundTint="@color/orange" android:layout_margin="@dimen/fab_margin" android:src="@drawable/ic_add" /> </android.support.design.widget.CoordinatorLayout>
layout/content_main.xml
<?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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="info.androidhive.fab.MainActivity" tools:showIn="@layout/activity_main"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Android Floating Action Button" /> </RelativeLayout>
values/fab_margin.xml
<resources> <dimen name="fab_margin">16dp</dimen> </resources>
jangan lupa masukan compile 'com.android.support:design:23.0.0'pada buid grandle :
ternyata ada caranya ya bang?
ReplyDeletemesin pemisah lcd