更改Android的一个TextView元素的字体大小 [英] change the font size of an textview element in android

查看:121
本文介绍了更改Android的一个TextView元素的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示2项在一个TextView。是他们没有办法更改单个项目的字体,一个TextView?

I am trying to display 2 items in a textview. Is their any way to change the font of the single item in a textview ?.

下面是我使用的XML

here is the XML which i am using

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

    <TextView
        android:gravity="center_horizontal"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:id="@+id/Rowtext"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:text="Listiems"
        android:background="@drawable/customshape"
         />

</LinearLayout>

感谢:)

推荐答案

一种方法是使用TextView.setText()方法,并使用HTML喂养它,像这样:

One way is to use TextView.setText() method and feed it with HTML, like this:

import android.text.Html;

String n = "<b>bold</b> <small>small</small>";
TextView tv = (TextView) findViewById(...)
tv.setText(Html.formHtml(n));

我经常使用它的一些小的标记(如让一部分大胆的或更小)

I often use it for some minor markup (like make part bolder or smaller)

这篇关于更改Android的一个TextView元素的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆