4

I got the Unicode of heart and diamond characters from this link and I am struggling to make them appear red in android TextView. Suprisingly same code changes color for hollow heart and diamond but not for solid ones. mycodes are below:

<TextView
   android:textColor="@android:color/holo_red_dark"
   android:id="@+id/testText1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />
<TextView
    android:textColor="@android:color/holo_red_dark"
    android:id="@+id/testText2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<TextView
    android:textColor="@android:color/holo_red_dark"
    android:id="@+id/testText3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<TextView
    android:textColor="@android:color/holo_red_dark"
    android:id="@+id/testText4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

// inside activity

    TextView tv1=(TextView)findViewById(R.id.testText1);
    TextView tv2=(TextView)findViewById(R.id.testText2);
    TextView tv3=(TextView)findViewById(R.id.testText3);
    TextView tv4=(TextView)findViewById(R.id.testText4);

    //  tv.setText(Html.fromHtml("\u2665"));


    tv1.setTextColor(Color.RED);
    tv1.setText(Html.fromHtml("<font color='red'>\u2665</font>"));
    tv2.setTextColor(Color.RED);
    tv2.setText(Html.fromHtml("<font color='red'>\u2666</font>"));
    tv3.setTextColor(Color.RED);
    tv3.setText(Html.fromHtml("<font color='red'>\u2661</font>"));
    tv4.setTextColor(Color.RED);
    tv4.setText(Html.fromHtml("<font color='red'>\u2662</font>"));

this is the snapshot of result in android enter image description here

theUturn
  • 1,101
  • 2
  • 12
  • 25

0 Answers0