I want to set an icon at the the end of my Toolbar
,which start another activity. My Toolbar
portion
<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="@dimen/abc_action_bar_default_height_material" android:background="#2B4AE0" app:theme="@style/ToolBarStyle"> <TextView android:id="@+id/headerText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@android:style/TextAppearance.Theme" android:textColor="@android:color/white" /> <RelativeLayout android:id="@+id/notification" android:layout_width="50dp" android:layout_height="match_parent" android:clickable="true" android:gravity="center" /> <ImageView android:layout_width="25dp" android:layout_height="25dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/bell_icon" /> </RelativeLayout> </android.support.v7.widget.Toolbar>
I tried
android:layout_alignParentEnd="true"
and setting margin left but it doesn't work correctly.
So to make it works, just copy and paste android:layout_gravity="end" to the ImageView /layout.
You can customize toolbars in the main window, editors, and dialogs. To display the toolbar, select the Toolbar command on the Options menu. A check mark indicates that the toolbar is active. To modify the toolbar, select Customize Toolbar on the Options menu (or double-click the toolbar area).
Now if you want to add other resolutions pictures to this drawable, just do it in the same manner. Step 5) And now go to the other folder which is Settings -> Androids-> drawable hdpi. And then go to your Android, then drawable, paste it here and inside this drawable-hdpi and click Ok.
Try adding this to your ImageView:
android:layout_gravity="end"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With