Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] Android Toolbar move icon of MenuItem to right side

Posted on November 14, 2022

Solution 1 :

you can always use android:actionLayout and create your own View that looks the way you want.

Example:

your_custum_view:

<LinearLayout xmlns_android="http://schemas.android.com/apk/res/android"
    xmlns_app="http://schemas.android.com/apk/res-auto"
    android_layout_height="wrap_content"
    android_layout_width="wrap_content"
    android_orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
    android_id="@+id/tvMenu"
    android_clickable="true"
    android_layout_height="wrap_content"
    android_layout_width="wrap_content"
    app_drawableRightCompat="@drawable/ic_up_arrow"
    android_drawablePadding="@dimen/margin_medium"
    android_focusable="true"
    android_gravity="center"
    android_padding="6dp"
    android_orientation="vertical"
    android_text="By Name" />

your_menu:

<item
        android_id="@+id/nv_create"
        android_icon="@drawable/ic_create_dw"
        android_title="Create"
        app_actionLayout="@layout/menu_sign"
        app_showAsAction="always" />

Solution 2 :

no such option in XML, but you can do it in Java/Kotlin. For start try to use ImageSpan and re-set this whole text in onCreateOptionsMenu. HERE you have some examples how to handle this span

Problem :

I have seen it done in apps like QuickPic where they managed to put the icon on right side

enter image description here

I tried to make the same thing but then I realized the icon seems to be hard-coded to appear on the left side.

enter image description here

Below is my menu.xml

<menu>
    <item android_id="@+id/sort_by_name"
        android_title="By name"
        android_icon="@drawable/ic_arrow_downward_gray_24dp"
        />

    <item android_id="@+id/sort_by_date"
        android_title="By date"/>

    <item android_id="@+id/sort_by_path"
        android_title="By path"/>
</menu>

So is there any way to move the icon to the right side?

Comments

Comment posted by snachmsm

more complex, but also more flexible solution with a lot more possibilities. +1

READ  [ANSWERED] Appium + android + python how to get URL that I've just clicked?
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress