【发布时间】:2021-07-05 16:45:00
【问题描述】:
我在我的应用程序中使用了BottomNavigationView,但是菜单项的文本重叠在小型设备的菜单图标上,如下图所示。
我试过这个:<dimen name="design_bottom_navigation_height" tools:override="true">56dp</dimen>
但在所有平板电脑中仍然存在重叠
我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/_50sdp" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
style="@style/bottomnavigation"
android:layout_width="match_parent"
android:layout_height="@dimen/_60sdp"
android:layout_gravity="bottom"
android:background="@color/colorbottomnavigation"
app:itemIconSize="@dimen/_20sdp"
app:itemIconTint="@drawable/bottomsheetcolor"
app:itemTextAppearanceActive="@style/BottomNavigationView.Active"
app:itemTextAppearanceInactive="@style/BottomNavigationView"
app:itemTextColor="@drawable/bottomsheetcolor"
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_navigation_menu" />
</FrameLayout>
这里是 menu.xml 文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home"
android:title="HOME" />
<item
android:id="@+id/navigation_prepwork"
android:icon="@drawable/ic_edit"
android:title="PREP WORK" />
<item
android:id="@+id/navigation_timetable"
android:icon="@drawable/ic_calendar"
android:title="TIME TABLE" />
<item
android:id="@+id/navigation_exam"
android:icon="@drawable/ic_exambottom"
android:title="ATTENDANCE" />
<item
android:id="@+id/navigation_more"
android:icon="@drawable/ic_more_24"
android:title="MORE" />
【问题讨论】:
-
您能添加您的菜单吗?我尝试使用您的代码,但它没有覆盖文本
-
只需将
BottomNavigationView高度设置为wrap_content -
@pratikvekariya 添加了
-
@javadroid 我试过但它不工作
-
你能从导航菜单中删除样式并在框架布局上方设置与导航菜单中相同高度的边距
标签: android android-layout bottomnavigationview