Screenshot 20210118 141035
Screenshot 20210118 141035

Create a text tag for Android with a custom tag background

To install

Coppy 2 class and in your widget


Use as normal TextView in Android

<com.nextsolutions.taglabeltext.TagLabelText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:gravity="center_vertical" android:text="Combo 2 Túi Nước Giặt Arie Matic Matic Đậm Đặc (2.4Kg/ Túi)" android:textColor="#24282C" android:textSize="16sp" android:textStyle="bold" app:tagBold="true" app:tagFirst="false" app:tagMarginStart="8dp" app:tagPaddingEnd="8dp" app:tagPaddingStart="8dp" app:tagRadius="6dp" app:tagSize="12sp" app:tagText="mStore mall" app:tagTextBackgroundColor="#E40C0C" app:tagTextColor="#FFF" />

With bond. You can make a method binding in the TagLabelText class as in the example. Remember to remove tag Android or App before the attr binding to use the binding. I do not know how that works :))

<com.nextsolutions.taglabeltext.TagLabelText ... text="@{`Combo 2 Túi Nước Giặt Arie Matic Matic Đậm Đặc (2.4Kg/ Túi)`}" tagText="@{boolean logic ? `mStore mall` : ``}" app:tagTextBackgroundColor="#E40C0C" app:tagTextColor="#FFF" />


 TagLabelText tagLabelText = findViewById(; tagLabelText.mSetText("LẠC TRÔI | OFFICIAL MUSIC VIDEO | SƠN TÙNG M-TP"); tagLabelText.tagText = "Sơn Tùng M-TP"; tagLabelText.setSpan();//apply properties of tagLabelText

Properties TagLabelText

  • boolean: tagFirst – The text view starts with the day if true is set. Text view ends with tag if false
  • boolean: tagBold – Make the style of the tag text bold if it is set to true. This property does not work if the textStyle of text is bold.
  • string: tagText – Text of the day
  • dimension: tagRadius – Roud Background Tag
  • dimension: tagSize – Size of the tag text. Should be equal to or lower than the text view
  • dimension: tagPaddingStart – Refill start of the day
  • dimension: tagPaddingEnd – Refill at the end of the day
  • dimension: tagMarginStart – MarginStart of the day
  • dimension: tagMarginEnd – MarginStart of the day
  • color: tagTextColor – Color of the tag text
  • color: tagTextBackgroundColor – Tag text colored background


Please enter your comment!
Please enter your name here