导航栏不对齐并显示图标

时间:2017-10-01 22:34:05

标签: android bottomnavigationview

我正在为我的应用构建一个导航栏,但它已经过时了。基本上,我希望我的导航栏看起来像这样:

enter image description here

但结果却是结果:

enter image description here

我已经为它写了所有必要的代码,但由于某种原因它给了我这个垃圾。以下是我的代码:

bottom_navigation_layout.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/action_menu"
        android:title="Menu"
        android:enabled="true"
        android:icon="@drawable/ic_menu"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_awards"
        android:title="Awards"
        android:enabled="true"
        android:icon="@drawable/ic_prizes"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_messaging"
        android:title="Messaging"
        android:enabled="true"
        android:icon="@drawable/ic_chat"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_game"
        android:title="Games"
        android:enabled="true"
        android:icon="@drawable/ic_game"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_contacts"
        android:title="Contacts"
        android:enabled="true"
        android:icon="@drawable/ic_friends"
        app:showAsAction="ifRoom"
        />
</menu>

activity_feed.xml

<RelativeLayout
    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="ca.ozbek.blur.view.FeedActivity">

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:menu="@menu/bottom_navigation_layout"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">
    </android.support.design.widget.BottomNavigationView>

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)