1
\$\begingroup\$

I was wondering how could I make in Android something like the popup messages seen in Candy Crush Saga, those messages like "Delicious!", "Tasty!" or similar:

enter image description here

As well as the score of each movement, they will pop up at first and then vanish:

enter image description here

How could I implement something like that in Android?

\$\endgroup\$
1
  • \$\begingroup\$ Javi, welcome to the site. I modified your question a bit. Asking for libraries, etc. is kind of like a polling question, it just produces a list. That's not really what this site is about. So I've changed your question to instead ask How to do it instead of Where can I find out how to do it. \$\endgroup\$
    – House
    Jul 9, 2013 at 17:06

1 Answer 1

3
\$\begingroup\$

Toast message might be the thing, that you are looking for. If you are not familiar with toast messages, i suggest that you take a look at this document page, about Toast messages:

Toast message

And then you should take a look at custom toast view document:

CustomToastView


Here's how to do it. First, create XML layout file and name it "cust_toast_layout.xml" and define the below layout.

cust_toast_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/relativeLayout1"
    android:background="@android:color/white">

<TextView
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:id="@+id/textView1" android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="Paresh N. Mayani"
    android:gravity="center"
    android:textColor="@android:color/black">
</TextView>

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:src="@drawable/new_logo"
    android:layout_below="@+id/textView1"
    android:layout_margin="5dip"
    android:id="@+id/imageView1">
</ImageView>

<TextView
    android:id="@+id/textView2"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="This is the demo of Custom Toast Notification"
    android:gravity="center"
    android:layout_below="@+id/imageView1"
    android:textColor="@android:color/black">
</TextView>

</RelativeLayout>

And Now inflate the above layout to create/show custom Toast notification:

CustomToastDemoActivity.java

LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.cust_toast_layout,
                                   (ViewGroup) findViewById(R.id.relativeLayout1));

    Toast toast = new Toast(this);
    toast.setView(view);
    toast.show();

(same answer can be found from here, thanks to Paresh Mayani) Adding image to toast

\$\endgroup\$
6
  • \$\begingroup\$ Link only answers are poor answers. I suggest you expand this answer by including an overview of the process for implementing these messages and the basic premise behind how they work. \$\endgroup\$
    – House
    Jul 9, 2013 at 16:58
  • \$\begingroup\$ Adding image to toast - link has perfect answer for this. \$\endgroup\$
    – Katu
    Jul 9, 2013 at 17:28
  • \$\begingroup\$ Great, take it and use it to expand this answer into more than just links. \$\endgroup\$
    – House
    Jul 9, 2013 at 17:31
  • \$\begingroup\$ A follow-up to what Byte said. We ask that you expand on the links because links are prone to link-rot and we want to future proof the answers as much as possible. \$\endgroup\$ Jul 9, 2013 at 17:39
  • \$\begingroup\$ Should be enough information, to implement that feature. \$\endgroup\$
    – Katu
    Jul 9, 2013 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .