我正在尝试在我的工具栏右边的经典“垂直三个点”之前添加一个图标,该图标位于我的可绘制目录中。这是我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/my_toolbar"
style="@style/HeaderBar"
android:layout_width="match_parent"
android:layout_height="@dimen/_20sdp"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/_3sdp">
<item
android:id="@+id/miCompose"
android:icon="@drawable/eraser"
android:title="Compose"
app:showAsAction="ifRoom"></item>
</androidx.appcompat.widget.Toolbar>
<TextView
android:id="@+id/textList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/my_toolbar"
android:layout_centerHorizontal="true"
android:textSize="26dp" />
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/my_toolbar" />
</RelativeLayout>
问题是我在网上收到此错误
android.view.InflateException:二进制XML文件第14行:二进制XML文件第14行:夸大类项目的错误
是。您可以在菜单方法
中使用图标设置支持操作栏
setSupportActionBar(toolbar)
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater = menuInflater
inflater.inflate(R.menu.menu_logout, menu)
return true
}
请在这里分享您的登录日志吗?