底部导航图标的颜色仅在第二次点击后才更改.如何在第一次点击时进行设置? [英] Bottom navigation icon color only changed after the second tap only.how to make on first tap?

查看:62
本文介绍了底部导航图标的颜色仅在第二次点击后才更改.如何在第一次点击时进行设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击底部导航图标时,图标的颜色不会更改.但是,如果再次单击,它将更改.

When I click bottom navigation icon the color of the icon is not changed.but if again I clicked it getting changed.

<android.support.design.widget.BottomNavigationView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            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/btm_slctd_clr"
            app:itemTextColor="@color/btm_slctd_clr"
            app:menu="@menu/bottom_nav_menu" />`

//btm_slctd_clr

//btm_slctd_clr

<?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_checked="true" android:color="@color/common_signin_btn_dark_text_pressed" />
           <item android:state_checked="false" android:color="@color/color_pressed"  />
    </selector>

推荐答案

如果您第一次触摸布尔变量,则可以使用布尔变量对其进行管理.条件,并在您的布尔变量具有错误值时设置背景.

You can manage it with a boolean variable if you touch it for the first time make boolean variable true and aftertouch make boolean variable false and the whole process will proceed under the condition and set your background when your boolean variable has a false value.

这篇关于底部导航图标的颜色仅在第二次点击后才更改.如何在第一次点击时进行设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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