setCloseButtonIcon() method doesn't change default Close button

后端 未结 2 1030
小蘑菇
小蘑菇 2021-01-01 19:03

I try to change default icon for Close Button in Chrome custom tabs (CustomTabsIntent.Builder)

Simple code for testing:

Bitmap closeIcon = BitmapFact         


        
2条回答
  •  渐次进展
    2021-01-01 19:28

    The close icon needs to be 24dp x 24dp. Something like this:

    
      
      
      
    
    

    In Kotlin, you can retrieve this drawable and add it to your builder like this:

    AppCompatResources.getDrawable(main, R.drawable.close_icon)?.let {
                DrawableCompat.setTint(it, Color.WHITE)
                builder.setCloseButtonIcon(it.toBitmap())
            }
    

    This answer has some more details.

提交回复
热议问题