英文:
BottomNavbar breaks when you add more than 3 elements
问题
以下是翻译好的内容:
我正在开发一个安卓应用程序,最初计划在底部导航栏中只有3个片段。然而,项目范围已扩展,我们决定添加第四个片段。在添加第四个片段时,容器的尺寸发生了问题,呈现出以下的样子:
这是我的 XML 代码:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/menu_navigation" />
我尝试了不同的属性来使其伸展,但它们最终只能将其放置在右侧,而不能向左展开,反之亦然。例如,如果我尝试在 layout_width 上使用 wrap_content,容器将会贴靠在左侧。
可能是解决这个问题的所需属性是什么呢?
英文:
I am working on an android application and it was agreed to only have 3 fragments in its bottom navigation bar. However, things have expanded and we decided to add another fragment. When adding the 4th fragment, the dimensions of the container break making it look like this.
This is my xml code.
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/menu_navigation" />
I have tried different properties to make it stretch but they end up putting it only to the right and not expanding left or vice versa. For instance if I was to try using wrap_content on the layout_width, the container would glue itself to the left.
What is the needed property that might be a solution to the problem?
答案1
得分: 0
这是一种自动措施,以防止标签重叠。
您可以通过在您的xml中添加 app:labelVisibilityMode="labeled"
来快速修复。
请注意,您应该使用支持库版本28进行此操作。
英文:
It's an automatic measure in order to not have labels overlap.
You can make a quick fix by adding app:labelVisibilityMode="labeled"
to your xml.
Note that you should use Use Support Library 28 for this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论