0

Is there any possibility to add notification in android tab bar like in iPhone Badges for tabs. I am not mean notification.Here i will place the iPhone badges screen shot also.enter image description here

If badges is not available in android, is placing a view in front of tab bar a fine solution?

Manikandan
  • 4,358
  • 5
  • 19
  • 13

4 Answers4

2

The possible way of doing this is to include android-viewbadger.jar in your Android Project and then using BadgeView Object.

salman khalid
  • 4,884
  • 4
  • 27
  • 33
1

There's no way to add a badge or small view on tabs. However you can create custom tabs and to add those tab on every view, override setContentView() in every activity and handle your custom tabs before setting content view.

Adeel Pervaiz
  • 1,336
  • 10
  • 11
0

You can create a custom Tab item xml and put a RelativeLayout with a background image and a centerInParent textView. Set RelativeLayout's visibility to GONE and whenever you want to show it, make it visible and set that textview to any text you want to.

<RelativeLayout
        android:id="@+id/tabBadge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="47dp"
        android:layout_marginTop="10dp"
        android:layout_toStartOf="@+id/tabTitle"
        android:visibility="gone" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/basket_item"
            android:contentDescription="@string/action_settings" />

        <TextView
            android:layout_centerInParent="true"
            android:id="@+id/tabBadgeText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColor="#ffffff"
            android:textSize="10sp" />
    </RelativeLayout> 

Also make sure to set that Relativelayout in your code while you are generating your tag like the code below so you can access to it whenever you want to:

// mTitle is the title of the tab

if (mTitle.equalsIgnoreCase("Basket")) {

//count is the TextView inside your badge

count = (TextView) view.findViewById(R.id.tabBadgeText);

//layout is the whole badge's layout

layout = (RelativeLayout) view.findViewById(R.id.tabBadge);

}

Hope it helps, if you need more information please feel free to ask.

Rudi
  • 4,304
  • 4
  • 34
  • 44
-1

Is Notification.number what you're looking for?

Felix
  • 88,392
  • 43
  • 149
  • 167