如何加粗文本Android String的一部分

Ali*_*Ali 6 java eclipse android

我想加粗“”文本的一部分,但我不知道这是我的文本:

<string name="apropos"> Le projet Marocherche : Bâtir au cœur d un portail professionnel, destiné aux entreprises marocaines, une création  conçue par des "professionnels pour des professionnels". 
Run Code Online (Sandbox Code Playgroud)

Nar*_*ngh 7

就这样使用 -

String sourceString = "<b>" + id + "</b> " + name; 
mytextview.setText(Html.fromHtml(sourceString));
Run Code Online (Sandbox Code Playgroud)

如果你想在 strings.xml 中编辑字符串,你可以这样做 -

<resource>
<string name="styled_welcome_message">We are <b>so</b> glad to see you.</string>
</resources>
Run Code Online (Sandbox Code Playgroud)


Mit*_*hun 1

您可以使用SpannableStringBuildernew StyleSpan(android.graphics.Typeface.BOLD)将字符串的一部分格式化为粗体。您可以在这里获得帮助