Android bottomnavigation view item icon size [duplicate]

╄→гoц情女王★ 提交于 2021-02-17 06:17:50

问题


I need to do a bottom navigation view in Android like this: I tried, and now I have something like this:

How can I increase size of the + icon? It will be static and bigger then another icons all the time. Other icons will change color when activated, but the size will remain the same.

Activity xml:

 <com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:itemBackground="@color/white"
    app:layout_anchor="@id/bottom_navigation"
    app:layout_constraintBottom_toBottomOf="parent"
    app:labelVisibilityMode="labeled"
    app:menu="@menu/bottom_navigation_main"
    tools:layout_editor_absoluteX="4dp" />

Bottom navigation view xml:

<item
    android:id="@+id/action_home"
    android:enabled="true"
    android:icon="@drawable/ic_home"
    android:title="@string/home"
    app:showAsAction="ifRoom"/>

<item
    android:id="@+id/action_notification"
    android:enabled="true"
    android:icon="@drawable/ic_notification"
    android:title="@string/notification"
    app:showAsAction="ifRoom"/>

<item
    android:id="@+id/action_add"
    android:enabled="true"
    android:title=" "
    android:icon="@drawable/ic_add_circle"
    app:showAsAction="ifRoom"
    app:itemIconSize="50px"/>

<item
    android:id="@+id/action_schedule"
    android:enabled="true"
    android:title="@string/schedule"
    android:icon="@drawable/ic_schedule"
    app:showAsAction="ifRoom" />

<item
    android:id="@+id/action_profile"
    android:enabled="true"
    android:title="@string/profile"
    android:icon="@drawable/ic_profile"
    app:showAsAction="ifRoom" />


回答1:


What you are trying can be achieved by using a 'Floating Action Button' on top of the Bottom Bar. The third item in your Bottom Bar can then just be a placeholder. No action, name and icon on it.

A layout for example with a Floating Action Button on top is presented in this post, see the post for more information regarding possibly the same issue you are facing.

You could also take a look at this. The newer Bottom Bar of Google that includes functionality with a Floating Action Button.



来源:https://stackoverflow.com/questions/58864046/android-bottomnavigation-view-item-icon-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!