1.在xml布局文件中创建toolbar布局,以及在res目录下创建menu目录并创建menu布局。
下面是toolbar布局:
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:popupTheme="@style/ToolbarPopupTheme"
android:background="@color/blue">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
android:orientation="horizontal">
<ImageView
android:id="@+id/toolbar_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrow_left"/>
<TextView
在fragment的toolbar中添加菜单
最新推荐文章于 2022-07-19 15:07:16 发布
本文介绍了如何在Android的Fragment中使用Toolbar并添加菜单。通过加载menu资源文件,实现ToolBar的菜单初始化。
摘要由CSDN通过智能技术生成