如何在服务器视图中格式化文本。赛马林 Android
How to format Text in a view from the Server. Xamarin Android
我正在使用 axml 视图开发 Xamarin Android 应用程序。其中一个视图要求一个视图上的文本视图可以从服务器进行配置。例如设置字体,能够使用项目符号等。关于如何实现这一点的想法的任何建议?下面是 axml :
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:textColor="@android:color/black"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:id="@+id/ParagraphTextView" />
只是在寻找如何实现这一点的想法。
好吧,这取决于您所说的可配置的含义。
在代码中你可以调用:
Typeface type = Typeface.CreateFromAsset(GetAssets(),"fonts/Roboto.ttf");
paragraphTextView.SetTypeface(type);
假设您的字体在您的资产文件夹中。如果您没有它们,您将不得不设法下载和存储它们,并从您存储它的任何地方获取字体资源。
对于要点,您可以尝试 HTML 通过:
var myText = "• An item with a bullet before it<br/>"
paragraphTextView.SetText(Html.FromHtml(myText));
有关更多项目符号的想法,请参阅:
How to add bulleted list to android application?
我正在使用 axml 视图开发 Xamarin Android 应用程序。其中一个视图要求一个视图上的文本视图可以从服务器进行配置。例如设置字体,能够使用项目符号等。关于如何实现这一点的想法的任何建议?下面是 axml :
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:textColor="@android:color/black"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:id="@+id/ParagraphTextView" />
只是在寻找如何实现这一点的想法。
好吧,这取决于您所说的可配置的含义。
在代码中你可以调用:
Typeface type = Typeface.CreateFromAsset(GetAssets(),"fonts/Roboto.ttf");
paragraphTextView.SetTypeface(type);
假设您的字体在您的资产文件夹中。如果您没有它们,您将不得不设法下载和存储它们,并从您存储它的任何地方获取字体资源。
对于要点,您可以尝试 HTML 通过:
var myText = "• An item with a bullet before it<br/>"
paragraphTextView.SetText(Html.FromHtml(myText));
有关更多项目符号的想法,请参阅: How to add bulleted list to android application?