底部导航栏中的android超过3个项目 [英] More than 3 items in bottom navigation bar android

查看:55
本文介绍了底部导航栏中的android超过3个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android的新手,我试图在底部导航栏中制作一个包含3个以上元素的应用.我能够显示它们,但它们在末尾聚在一起,只有三个可见.这是我的代码:

I am new to android and I am trying to make an app with more than 3 elements in the bottom navigation bar. I am able to display them but they are getting clustered at the end and only three are visible properly. Here is my code:

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottomNavigation"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:elevation="15dp"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    app:menu="@menu/bottom_nav_items" />

这是视图的图像:这是快照

我被卡住了,请帮忙..

I am stuck please help..

推荐答案

我不确定,但是据我所知,使用底栏不能伴随3个以上的项目,而不会扭曲对齐方式.无论如何,您可以做一个水平方向的线性布局,然后将这些图标设置为图像视图,然后将其权重设置为1.

I am not sure, but to my knowledge, it is not possible to accompany more than 3 items using the bottom bar, without distorting the alignment. What you can do anyways is make a linear layout with horizontal orientation, and in that set those icons as image views and then make their weight as 1.

这是代码

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:gravity="center"
    android:layout_alignParentBottom="true"
    android:background="#fff">

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="(YOUR IMAGE SOURCE)"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:layout_weight="1"/>

然后是其他类似的图像视图.

And then other image views like this.

这篇关于底部导航栏中的android超过3个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆