Reputation: 881
I am trying to show a count indicator with some of the associated menu items. How do I go about doing that? I tried creating TextView children for menu items, but they don't seem to work. Here's a mockup of what I am trying to achieve (see notifier next to the Gallery option)
Upvotes: 1
Views: 1845
Reputation: 27515
If you are using NavigationView
NavigationView provides a convenient way to build a navigation drawer, including the ability to creating menu items using a menu XML file. We’ve expanded the functionality possible with the ability to set custom views for items via app:actionLayout or using MenuItemCompat.setActionView().
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
<item android:id="@+id/nav_item1"
app:showAsAction="always"
android:title=""
app:actionLayout="@layout/menu_item_layout" />
</group>
</menu>
you can customize as you want
<?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">
<TextView android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="Item text" />
</RelativeLayout>
Upvotes: 4
Reputation: 3711
you can create FrameLayout
in which add your Titile TextView
and above that your Count TextView
as follows
t
<FrameLayout>
<TextView></TextView> //your titile TextView
<TextView></TextView> //your count TextView which has gravity of top right and circular background drawable
</FrameLayout>
Upvotes: 1