Creating an empty Drawable in Android

前端 未结 8 897
陌清茗
陌清茗 2021-02-05 00:15

Creating a Drawable that is completely empty seems like a common need, as a place holder, initial state, etc., but there doesn\'t seem to be a good way to do this... at least in

相关标签:
8条回答
  • 2021-02-05 00:59

    For me it didn't work when I tried to use @android:id/empty when making an empty drawable. For me, @android:color/transparent was the one.

    0 讨论(0)
  • 2021-02-05 01:00

    To create an empty Drawable image, you may use ShapeDrawable with transparent color:

    val shapeDrawable = ShapeDrawable(OvalShape())
    shapeDrawable.paint.color = context.getColor(android.R.color.transparent)
    

    If the image size is important, use:

    shapeDrawable.intrinsicWidth = 100
    shapeDrawable.intrinsicHeight = 100
    
    0 讨论(0)
提交回复
热议问题