Tuesday, 13 July 2021

Cannot draw on Chip when text alignment is center

I am extending Chip class to perform some drawing over it for my lib , my use case is more complex but for simplicity let's say i am just drawing a diagonal line

my code

class MyChip (context: Context,attributeSet: AttributeSet) : Chip(context,attributeSet){

override fun onDraw(canvas: Canvas) {
    super.onDraw(canvas)
    //just want to draw a diagonal line
    canvas.drawLine(0f,0f,width/1f,height/1f,paint)
  }
 }

xml

<com.abhinav.chouhan.loaderchipdemo.MyChip
    android:layout_width="200dp"
    android:layout_height="50dp"
    android:textAlignment="center"
    android:text="SOME TEXT"/>

when i don't have attribute android:textAlignment="center" everything works fine , but with that attribute we can not draw anything on chip. I tried everything but couldn't figure out why is it happening.

Please Help



from Cannot draw on Chip when text alignment is center

No comments:

Post a Comment