I am trying to add badges to the icons in my android app. e.g. in the facebook app(for iPhone), in the home page the number of pending requests is shown on the requests icon.
Can someone provide any links/ideas on how to do this?
Thanks
Navigate to the resources directory (app > src > main > res) and expand out some of the mipmap folders. These mipmap folders are where you should put the launcher icon assets for your Android app.
If you really want to do it. Use a FrameLayout
which contains an ImageView
with your icon and a TextView
with a ninepatch drawable as background in the right corner. Add margins to the ImageView
if you want the badge to be a bit outside the icon.
Thanks Alexanderblom ,for the hints.i used that logic and manage to create badge on a internal imageicon.here is the xml file.and you have to just create a red circle on the drawable.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frameLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/textView1" android:layout_width="20dip" android:layout_height="20dip" android:text="5" android:textColor="@color/black" android:textStyle="bold" android:padding="2sp" android:gravity="center" android:background="@drawable/circle" android:layout_gravity="top|right" /> </FrameLayout>
and the circle.xml is
<item> <shape android:shape="oval"> <solid android:color="@android:color/black" /> </shape> </item> <item android:top="1dp" android:left="1dp" android:right="1dp" android:bottom="1dp"> <shape android:shape="oval"> <solid android:color="@color/Red" /> </shape> </item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With