Multi-State Toggle Button

后端 未结 5 1150
别那么骄傲
别那么骄傲 2020-12-03 03:10

In the app I\'ve been working on, I would like to have a multiple-state (in my case, three) toggle button, instead of the two that ToggleButton provides. I\'ve

5条回答
  •  失恋的感觉
    2020-12-03 03:47

    Chip is a very good native option.

     
    
          
    
               
               
    
       
    

    binding.chipGroup.setOnCheckedChangeListener { chipGroup, i -> 
        when (i) {
            binding.firstChip -> {
                binding.firstChip.setChipBackgroundColorResource(R.color.colorAccent)
            }
            else -> {} 
        }
    }
    binding.firstChip.isChecked = true  //default
    

    GL

    Source

提交回复
热议问题