0

This problem I searched a lot over Internet. All shows suggestion for v4 / v7 Toolbar. But mine is androidx.

My problem is under Toolbar I created a ImageView successfully. It appears on left most side. I want to align it right hand side. Align partent = true is not working, what ever the parent layout relative or Linear.

Code example is

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay">


        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
          ``` android:layout_alignParentEnd="true" ``` **// This is not working **
            android:src="@drawable/app_icon"/>
    </androidx.appcompat.widget.Toolbar>




</com.google.android.material.appbar.AppBarLayout> 

I need to imageview at righthand side of toolbar.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    use `android:layout_gravity="end` inside `ImageView`. – ADM May 14 '20 at 04:52
  • 1
    Thanks, ADM. It's working. But gravity suggestion not listed. Copy and paste your code, and it worked. Thanks Again ! – Sanchyan Chakraborty May 14 '20 at 17:38
  • @ADM: is it worth creating an answer for this, or might a suitable duplicate exist? – halfer May 19 '20 at 19:03
  • Does this answer your question? [Add custom view to the right of toolbar](https://stackoverflow.com/questions/33909621/add-custom-view-to-the-right-of-toolbar) – ADM May 20 '20 at 04:29

0 Answers0