-2

Does anyone have an idea about how to customize the options menu item?. so I need to change display text below icon of the option menu item in a toolbar.

Damini Mehra
  • 3,257
  • 3
  • 13
  • 24

2 Answers2

0
Use Custom toolbar :-

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorWhite"
    android:elevation="0dp"
    android:minHeight="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

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

        <ImageView
            android:id="@+id/back_imageView"
            android:layout_width="@dimen/card_h"
            android:layout_height="@dimen/card_h"
            android:layout_centerVertical="true"
            android:contentDescription="@string/app_name"
            android:paddingBottom="@dimen/small_margin"
            android:paddingRight="@dimen/med_margin"
            android:paddingTop="@dimen/small_margin"
            android:src="@mipmap/back" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:orientation="vertical">


            <ImageView
                android:id="@+id/right_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/iv_dob"
                android:layout_gravity="center"
                android:contentDescription="@string/app_name" />

            <TextView
                android:id="@+id/first_textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/lato_bold"
                android:text="@string/app_name"
                android:textAllCaps="true"
                android:textColor="@color/colortext"
                android:textSize="@dimen/normal_text_size" />
        </LinearLayout>


    </RelativeLayout>
</android.support.v7.widget.Toolbar>
Anita
  • 39
  • 1
  • 7
0

You can use custom action Layout and put into menu Item:

Here is XML for menu.

<menu 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:Eventapp="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/action_create"
android:actionLayout="@layout/action_view_details_layout"
android:orderInCategory="50"
android:showAsAction = "always"/>

</menu>

The Layout is

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/create"/>

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:src="@drawable/icon"/>

</LinearLayout>

this will show the icon and the text in vertical fashion.

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43