I am trying to display some text in a TextView with @string, the problem is i cant seem to be able to change the color of part of the text. I dont want to use Java to do this as all other questions suggest, since this is the default TextView text.
I've tried using <string name="myString"><font color="#00ff00">My String</font></string>
and font fgcolor="#00ff00"
but they dont seem to work.
I've tried with your given string and it is works for me. Here is an example
Create <TextView>
inside any layout
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text" />
Create text
string inside strings.xml
file
<string name="text"><font color="#00ff00">Hello</font> <font
color="#FF0000">World</font></string>
And you can see the result
<TextView android:id="@+id/resultTextView" android:text="@string/reusltDefText" android:textAlignment="viewStart" android:textColor="#000000" android:textSize="12sp" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/divider" app:layout_constraintStart_toStartOf="parent" />
and the string look like this: ` <string name="reusltDefText"><font color="#ff0000">My String!</font></string>`I figured it out! it was a stupid mistake from me. Thank you, and sorry
@kriskotooBG It's always pleasure to help. :)