activity_home.xml我不知道为什么底部导航栏的图标没有显示。高度设置为包装内容,高度为0dp,告诉我根本没有图标。这是代码:
bottom_navigation.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_home"
android:title="Home"
android:icon="@drawable/ic_home"
app:showAsAction="always"/>
<item
android:id="@+id/menu_myEvents"
android:title="My Events"
android:icon="@drawable/ic_event"
app:showAsAction="always"/>
<item
android:id="@+id/menu_myConversations"
android:title="My Conversations"
android:icon="@drawable/ic_conversations"
app:showAsAction="always"/>
</menu>
activity_home.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activityHome"
android:background="@color/colorPrimary">
<Button
android:id="@+id/btnLogOut"
android:layout_width="115dp"
android:layout_height="75dp"
android:text="log out"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/btnLogOut"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/bottom_navigation"/>
</androidx.constraintlayout.widget.ConstraintLayout>
(我知道约束现在都疯了,请忽略!)