Android RemoteView textStyle 粗体

1 android widget textview remoteview xamarin

此问题与C#使用编写的 Android 小部件有关Xamarin

text style我想为bold小部件布局的元素设置文本视图。更改文本本身效果很好,但我无法设置其他属性。

这是构建更新的方法的一部分

remoteViews.SetTextViewText(Resource.Id.widget_info, nextItemText[1]);
if (element.InProgress)
{
    // this is my try to set textstyle to bold
    remoteViews.SetString(Resource.Id.widget_info, "textStyle", "bold");
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能设置text stylebold

提前致谢!

And*_*nie 6

我不了解 Xamarin/C#,但这就是你在 Java 中的做法,也许你可以调整它:

SpannableString s = new SpannableString("To boldly go where no man has gone before"); 
// make the word "boldly" be in bold
s.setSpan(new StyleSpan(Typeface.BOLD), 3, 9, 0); 
remoteViews.setTextViewText(R.id.txt, s); 
Run Code Online (Sandbox Code Playgroud)