Use of Android Snackbar

Source: Internet
Author: User

Snackbar is similar to a toast, used to present information to the user, and to interact with the user, which can display a button to get the user's action. It features the following:

    1. As a child view of the Android.support.design.widget.CoordinatorLayout, appears at the bottom of the page.
    2. You can display a string and a button. Toast can only display text and cannot be interacted with by buttons and users
    3. Supports swipe right gestures: swipe the finger to the right on Snackbar, then close Snackbar
    4. Support Set a time, timeout auto shutdown snackbar

How to use:

1. Place the parent layout Coordinatorlayout

<android.support.design.widget.coordinatorlayout 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:fitssystemwindows= "true"    android:background= "#2a5caa" >     </android.support.design.widget.CoordinatorLayout>

2. Perform the display snackbar in the code

Snackbar.make (View, "text", Snackbar.length_long)                        . Setaction (new  View.onclicklistener () {                            @Override                              Public void OnClick (View v) {                                alert ("xxxxx");                            }                        }). Show ();

Complete.

Use of Android Snackbar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.