Android 底部导航图标色调
我刚刚将底部导航添加到我的android应用程序中,但其中四个图标中有两个没有正确的颜色 这是Android Studio预览版中的外观: 这就是它在设备上的外观: 所有图标都在我的可绘制文件夹中 这是底部导航的xml:Android 底部导航图标色调,android,xml,menu,bottomnavigationview,Android,Xml,Menu,Bottomnavigationview,我刚刚将底部导航添加到我的android应用程序中,但其中四个图标中有两个没有正确的颜色 这是Android Studio预览版中的外观: 这就是它在设备上的外观: 所有图标都在我的可绘制文件夹中 这是底部导航的xml: <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_pa
<android.support.design.widget.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="@color/colorAccent"
app:itemTextColor="@color/colorAccent"
app:menu="@menu/bottom_navigation_main" />
这是项目的xml:
<item
android:id="@+id/action_home"
android:enabled="true"
android:icon="@drawable/ic_home_white_48dp"
android:title="@string/home"
app:showAsAction="always" />
<item
android:id="@+id/action_requests"
android:enabled="true"
android:icon="@drawable/ic_collections_white_48dp"
android:title="@string/requests"
app:showAsAction="always" />
<item
android:id="@+id/action_profile"
android:enabled="true"
android:icon="@drawable/ic_account_circle_white_48dp"
android:title="@string/profile"
app:showAsAction="always" />
<item
android:id="@+id/action_recents"
android:enabled="true"
android:icon="@drawable/ic_schedule_white_48dp"
android:title="@string/recents"
app:showAsAction="always" />
希望您能帮助我。在创建选择器时,始终在末尾保留默认状态,否则将只使用默认状态。您需要将选择器中的项目重新排序为:
与BottomNavigationBar一起使用的状态为state_checked not state_selected。代码中似乎没有问题……但一旦尝试清理项目或重新启动Studio。好的,在清理、重建并重新启动Android Studio后,现在所有4个图标都显示为亮白色。但我一点击其中一个,最后一个就会变成难看的灰色。再次单击项目后,第二个项目也会返回灰色。也许ItemSelectedListener中有问题<代码>案例R.id.action\u home:replaceFragmentFrame(homeFragment);item.setChecked(真);中断代码>当然每一项都要这样做。然后把你的代码也放进去。也许有人会帮助你。谁知道你的问题。如果我知道,我会告诉你。