Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 所有类型的'✔️';Android上有字符吗?(对于文本视图)_Java_Android_Unicode_Character Encoding_Character - Fatal编程技术网

Java 所有类型的'✔️';Android上有字符吗?(对于文本视图)

Java 所有类型的'✔️';Android上有字符吗?(对于文本视图),java,android,unicode,character-encoding,character,Java,Android,Unicode,Character Encoding,Character,我想知道什么是所有类型的'✔️' Android上可用的字符(用于文本视图) Nota:我需要能够改变它们的颜色(我只是看到有些不可能改变颜色) 谢谢 您可以: 在XML中设置文本和颜色: TextView中的所有字符将具有相同的颜色-您的字符(✔️) 此外,您还可以将字符提取到strings.xml,以便在少数地方重用它 <TextView android:layout_width="match_parent" android:layout_height="match_p

我想知道什么是所有类型的'✔️' Android上可用的字符(用于文本视图)

Nota:我需要能够改变它们的颜色(我只是看到有些不可能改变颜色)

谢谢

您可以:

在XML中设置文本和颜色:
TextView
中的所有字符将具有相同的颜色-您的字符(✔️) 此外,您还可以将字符提取到
strings.xml
,以便在少数地方重用它

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:text="✔"
    android:textColor="#f0f"
    android:textSize="100sp" />
但是颜色(
#0F0
)是在XML中设置的:

<TextView
    android:id="@+id/text_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:textColor="#0F0"
    android:textSize="100sp" />
XML中只有空的
TextView

<TextView
    android:id="@+id/text_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:textColor="#00F"
    android:textSize="50sp" />

有许多帖子介绍了如何使用
SpannableString
机制:


请花一点时间查看以下操作指南:和。您没有添加任何代码。某些字体带有复选标记符号
\u2713
。这样的符号可以着色。您需要进行富文本处理。
String first = "stack";
String second = "overflow";
SpannableString spannable = new SpannableString(first + "\u2713" + second);

ForegroundColorSpan color = new ForegroundColorSpan(ContextCompat.getColor(this, android.R.color.holo_red_dark));

spannable.setSpan(
        color,
        first.length(),
        first.length() + 1,
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView textView = findViewById(R.id.text_view);
textView.setText(spannable);
<TextView
    android:id="@+id/text_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:textColor="#00F"
    android:textSize="50sp" />