I have a TextView with a random background color (could be any color really). I also have a text on this Textview that need to be readable. I assume the best solution is to highlight the said text in white and set the text color to black.
My question is: Is it possible to highlight the text inside a texview from the XML?
I have the following in my layout:
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/colorButton4"
android:layout_gravity="right|bottom"
android:background="@drawable/layout_border"
android:layout_marginRight="30dp"
android:layout_marginBottom ="30dp"
android:clickable="true"
android:onClick="onClick"
android:gravity="center"
android:textColorHighlight="@color/bgWhite"
android:textColor="@color/Black"
android:text="5431354" />
But it deosn't highlight the text.
https://github.com/datanapps/HighlightedTextView
<datanapps.highlightedtextview.HighLightTextView
android:id="@+id/tv2"
android:layout_below="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers."
android:textColor="@color/white"
app:fontFamily="serif"
android:lineSpacingExtra="50sp"
android:layout_marginTop="20dp"
android:textSize="20sp"
android:textAlignment="viewEnd"
app:highLightColor="@color/blue"
/>