I need to make a view like this one:
I already have a TextView
with CompoundDrawable
setted by:
textView.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
context.getDrawableCompat(R.drawable.ic_arrow_forward),
null
)
And now I just need to add a red circle around TextView's
text.
Here's my XML
with red background:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/red"/>
</shape>
But because of CompoundDrawable
arrow the size of my TextView
increases (text + drawable), so when I add a android:background
attribute to my TextView
it applies to the arrow as well.
Here's how it looks like:
Is there a way to set the background only to text of TextView
?
Sadly, but the only solution I've found is to separate the drawable from counter and set background to counter only.