Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the indicator bubble on top of the imageview?

I have a string value (i.e.: numbers 1, 2, 3, ...) and I should display those on the top right corner of my ImageView.
How can I do that in android?
I have attached an image below in which I show arrows: I want something like that to display over my ImageView?

http://i.stack.imgur.com/5zPQt.png

Please anyone can help me out?

like image 777
arun Avatar asked Feb 10 '14 13:02

arun


People also ask

How do you show the full size image in pop up when clicking the picture on android?

How to show the full size image in popup on clicking the image in android. Below is the code that will show the full size image in a dialog box popup without defining layout xml file . int a=v. getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .

What is the difference between ImageView and ImageButton?

ImageButton has the same property as ImageView . Only one feature is extra, which is, images set through ImageButton are clickable, and actions can be attached with them upon clicking. Just like a button, the setOnClickListener() can be used to set an event listener for click event on this.


2 Answers

try this : create layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dip"
android:focusable="true" >

<ImageView
    android:id="@+id/icon"
    android:layout_width="60dip"
    android:layout_height="60dip"
    android:layout_marginTop="8dp"
    android:background="@drawable/logo"
    android:contentDescription="image"
    android:scaleType="center" />
<TextView
    android:id="@+id/txt_count"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="-10dip"
    android:layout_toRightOf="@+id/icon"
    android:background="@drawable/badge_count2"
    android:contentDescription="badge"
    android:gravity="center"
    android:text="1"
    android:textColor="@color/White"
    android:textStyle="bold"
    android:visibility="visible" />

</RelativeLayout>

And create drawable\badge_count2.xml for rectangle

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<solid android:color="@color/red" >
</solid>

<stroke
    android:width="2dp"
    android:color="#FFFFFF" >
</stroke>

<padding
    android:bottom="2dp"
    android:left="7dp"
    android:right="7dp"
    android:top="3dp" />

<corners android:radius="10dp" >
</corners>

And create values\color.xml and add:

 <color name="red">#e50822</color>

OutPut: enter image description here

Update: try to create drawable\badge_count2.xml for circle

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@color/red" />

<stroke
    android:width="2dp"
    android:color="#FFFFFF" />
</shape>
like image 194
M D Avatar answered Oct 28 '22 09:10

M D


For ease and cover a lot of views you may use View badger library. This library provides different styles and animations for these badgers too. You may find library and demo project here.

enter image description here

like image 34
Adnan Avatar answered Oct 28 '22 08:10

Adnan