我想在我的工具栏
的末尾设置一个图标,以启动另一个 Activity 。
我的工具栏
部分
<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"
并设置了 margin left 但它不能正常工作。
最佳答案
尝试将其添加到您的 ImageView 中:
android:layout_gravity="end"
关于android - 如何在工具栏的末尾设置一个图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27923944/