how do I change the solid color of a ripple drawable?

前端 未结 1 1566
萌比男神i
萌比男神i 2021-01-16 22:51



        
1条回答
  •  时光说笑
    2021-01-16 23:08

    You should add an id to items to access them via java/kotlin.
    check this background XML file

    
    
       
          
             
            
         
      
    
    

    to change the solid color of this, on constraintLayout background, this drawable XML is applied

    val background = constraintLayout.background as RippleDrawable
    val bgShape = background.findDrawableByLayerId(R.id.fab_shape) as GradientDrawable
    bgShape.color = color
    

    for reference read this

    0 讨论(0)
提交回复
热议问题