在工具栏末端设置图标 [英] set icon at the end of toolbar
本文介绍了在工具栏末端设置图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的工具栏,启动另一个活动的结束设定一个图标。 我的工具栏部分
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>
我试过
android:layout_alignParentEnd="true"
和设置留有余量,但它不能正常工作。
and setting margin left but it doesn't work correctly.
推荐答案
尝试添加到您的ImageView:
Try adding this to your ImageView:
android:layout_gravity="end"
这篇关于在工具栏末端设置图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文