gpt4 book ai didi

android - 以粗体显示文本

转载 作者:行者123 更新时间:2023-12-02 10:29:21 25 4
gpt4 key购买 nike

如何在 xml 的图形布局中以粗体显示文本?我希望我的标题为粗体,而结果为正常格式。谢谢。我希望你能帮我解决这个问题。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/coordinates"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/instruction" />

<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/result" />

<Button
android:id="@+id/btn_process"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btn_text" />

<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="300dp"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Original" />

<ImageView
android:id="@+id/imageSource"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/test_ideal_graph" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Result" />

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/imageAfter"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</ScrollView>

</LinearLayout>

最佳答案

strings.xml

<string name="your_string_name"><b> I am bold text</b> And I am not bold</string>

使用此方法可以更灵活地设置文本格式。

还记得使用 Html.fromHtml("your html string"); 在 TextView 中设置文本

例如

String s="<b> I am text in bold </b> and I am not.";
TextView t=new TextView();
t.setText(Html.fromHtml(s));

关于android - 以粗体显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15062395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com