Android Floating Action Button

এন্ড্রোইড ফ্লোটিং অ্যাকশন বাটন হলো গোলাকার বাটন। এটা ইউজার ইন্টারফেসের উপরে অবস্থান করে এবং ক্লিক করলে কোন ইভেন্ট সংঘটিত করে। এন্ড্রোইড ফ্লোটিং অ্যাকশন বাটন 3টা সাইজ এ ডিফাইন করা যায় normal এবং mini এবং auto ।

Add Design Support Libray In app Level Gradle.build File . Then Go To Mainactivity.xml file

  <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:src="@android:drawable/ic_dialog_email"/>

Go To MainActivity.java And Add This Line

    FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // We are showing only toast message. However, you can do anything you need.
                Toast.makeText(getApplicationContext(), "You clicked Floating Action Button", Toast.LENGTH_SHORT).show();
            }
        });

Attributes of Android Floating Action Button Widget

Some of the popular attributes of android Floating Action Button widget are –

Sr.XML AttributesDescription
1app:fabCustomSizeSets the size of the button in pixels. If set to NO_CUSTOM_SIZE, custom size will not be used and size will be calculated based on the fabSize attribute.
2app:fabSizeSets the size of the button. There are 3 options available – normal, mini and auto. normal is larger than mini. auto will choose size based on the screen size.
3app:elevationSets elevation of the button.
4app:rippleColorSets ripple colour for button
5app:useCompatPaddingSets inner padding of button on platform lollipop and after.

Published by

Unknown's avatar

Nusrat Faria

I Am A Web Developer And A Android Developer. This Is My Personal Blog So Noted My Work For Helping People .

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.