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?
Please anyone can help me out?
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 .
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.
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:
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>
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.
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