Search code examples
androidxmliconstoolbarinbox

how to add message inbox icon in toolbar?


in android toolbar i have a item that show inbox message.

<item
    android:id="@+id/message"
    android:orderInCategory="200"
    android:title="@string/message"
    android:icon="@drawable/message"
    app:showAsAction="always" />

icon in toolbar

how can i add like this icon(programmity)? can i make a xml file? example of toolbar that show inbox message(toolbar is RTL and Persian) Persian toolbar that have a inbox icon


Solution

  • I think that I've already solved a similar problem. Here's my post from Add a TextView to the elements of a Toolbar

    First, please learn how to create your own customized toolbar.

    Search for topics like this: http://code.tutsplus.com/tutorials/getting-started-with-android-creating-a-customized-toolbar--cms-24223

    Then you can create your toolbar as below ;-)

    Here is an example of your wannabe toolbar

            <ImageView
                android:id="@+id/shopping_bag"
                android:layout_width="44dp"
                android:layout_height="44dp"
                android:src="@drawable/bag"
                android:layout_alignParentLeft="true"
                android:layout_centerInParent="true"></ImageView>
    
            <ImageView
                android:id="@+id/arrow"
                android:layout_width="48dp"
                android:layout_height="wrap_content"
                android:src="@drawable/usability_bidirectionality_guidelines_when3"
                android:layout_alignParentRight="true"></ImageView>
    
            <ImageView
                android:id="@+id/number"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:src="@drawable/one"
                android:layout_alignTop="@+id/shopping_bag"
                android:layout_alignRight="@+id/shopping_bag"/>
    
        </RelativeLayout>
    

    and it looks like:

    enter image description here

    To have a better look, find Material Design inspired icons.

    I also see that you would need some Persian icons. If you cannot find them I would help you to create an example.

    If you have any question please free to ask

    Hope it help