N
N
newdancer2017-02-06 13:23:45
Android
newdancer, 2017-02-06 13:23:45

How to add number on hamburger on navigation drawable?

How to add number on hamburger on navigation drawable?
185483f1d39a412b96d84bd5fa76461f.png
tried doing something like this:

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:titleTextColor="@color/colorWhite"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" >

            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/openMenu"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:src="@drawable/drawable"/>

                <TextView
                    android:id="@+id/badger"
                    android:layout_width="16dp"
                    android:layout_height="16dp"
                    android:layout_gravity="end|right|top"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/badge"
                    android:gravity="center"
                    android:text="1"
                    android:textColor="@color/colorWhite"/>

            </FrameLayout>

            </android.support.v7.widget.Toolbar>

but the icon is not there and is not displayed that way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
androidzakzak, 2017-02-08
@newdancer

If not on the menu, then something like this.

<?xml version="1.0" encoding="utf-8"?>
<pakage.custom_view.ActionView 
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="36dp"
         android:layout_height="36dp"
         android:background="@android:color/transparent"
         android:orientation="vertical"
         android:padding="4dp">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:background="@android:color/transparent"
        tools:src="@drawable/ic_basket"/>

    <TextView
        android:id="@+id/counter"
        style="@style/Counter.White"
        android:layout_alignParentRight="true"
        tools:text="1"/>
</pakage.custom_view.ActionView>

And in the menu you can pin it, here's an example:
<android.support.design.widget.AppBarLayout
                android:id="@+id/toolbar_layout"
                style="@style/ToolBarStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:elevation="0dp"
                app:theme="@style/ToolBarStyle"
                >

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    style="@style/ToolBarStyle"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                    app:theme="@style/ToolBarStyle"
                    />
            </android.support.design.widget.AppBarLayout>

            <TextView
                android:id="@+id/main_counter"
                style="@style/Counter.White"
                android:layout_marginLeft="32dp"
                android:layout_marginTop="@dimen/main_counter_top_margin"
                android:clickable="false"
                android:focusable="false"
                app:layout_anchor="@+id/toolbar"
                app:layout_anchorGravity="left|top"
                />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question