1

I am using bullet in a TextView in XML code and I don't know why its color is red in some devices while my TextView color is white. It can be because of device default theme. How can I make it white.

Activity theme:

 <style name="AppThemeOnBoarding" parent="Theme.AppCompat.Light.NoActionBar.FullScreen">
</style>

My XML code:

<TextView
   android:gravity="center"
   android:padding="20dp"
   style="@style/TextView_shadow"
   android:layout_centerInParent="true"
   android:alpha="0.9"
   android:textSize="13sp"
   android:textColor="#ffffff"
   android:text="i Verbindung am besten mit: \n✔ ABC\n✔ XYZ"
   android:id="@+id/fitbit_connectiondesc"
   android:layout_below="@id/fitbit_label"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"/>

Result

abdul khan
  • 843
  • 2
  • 7
  • 24

6 Answers6

1

check this image

 tv.setText(Html.fromHtml("i Verbindung am besten mit:" + "<font color=\"#ffffff\">" +"<br>✔ ABC <br>✔ XYZ"+ "</font><br><br>"));

//xml like

<TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
Rajesh Satvara
  • 3,842
  • 2
  • 30
  • 50
1

I found an alternate method to achieve this. I am using Spannable to set "bullet tick" Image in between TextView, an alternate for bullet. This is working perfectly.

String string = "i Verbindung am besten mit: \n ABC \n XYZ";
String abc = "ABC";
String xyz = "XYZ";

SpannableString spannableString = new SpannableString(string);

int startPosition1 = string.indexOf(abc);
int startPosition2 = string.indexOf(xyz);
    
Bitmap bullettick = BitmapFactory.decodeResource(getResources(), R.drawable.tick_bullet);
    
spannableString.setSpan(new ImageSpan(context,bullettick ), startPosition1-2, startPosition1, Spannable.SPAN_INCLUSIVE_INCLUSIVE );
spannableString.setSpan(new ImageSpan(context, bullettick ), startPosition2-2, startPosition2, Spannable.SPAN_INCLUSIVE_INCLUSIVE );
textview.setText(spannableString);
textview.setMovementMethod(LinkMovementMethod.getInstance());
tskulbru
  • 2,336
  • 1
  • 20
  • 38
abdul khan
  • 843
  • 2
  • 7
  • 24
0

use this programmatically to set the white color

mTextView.setTextColor(Color.parseColor("#ffffff"));
dielan
  • 86
  • 9
0

Refer TextView in your Activity and set text in html format as in

TextView fitbitTV = (TextView) findViewById(R.id.fitbit_connectiondesc);
String content = "<font color='#FFFFFF'>i Verbindung am besten mit: \n✔ ABC\n✔ XYZ</font>";
fitbitTV.setText(Html.fromHtml(content));
Rajan Kali
  • 12,627
  • 3
  • 25
  • 37
0

Create html string with font as below.

 Html.fromHtml("<![CDATA[<font color='#145A14'>text</font>]]>");

this is sample code.

or

Use 'android:textColor' in text style.

Keyur Thumar
  • 608
  • 7
  • 19
0

use this in style

<item name="android:textColor">@color/AppThemeOnBoarding</item>

<style name="AppThemeOnBoarding" parent="Theme.AppCompat.Light.NoActionBar.FullScreen">
 <item name="android:textColor">@color/AppThemeOnBoarding</item>
</style>
nzala
  • 374
  • 4
  • 10