martes, 7 de enero de 2014

Android: Bold text

Programatically

TextView title = (TextView) convertView.findViewById(R.id.highlight_title);
title.setTypeface(null, Typeface.BOLD);
title.setText(calendaredProgram.getProgram().getTitle());

you can also do the following

Spanned fromHtml = Html.fromHtml("<b>Text</b>");
String text = fromHtml.toString();


In the view layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    ...

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

    ...

</RelativeLayout>
values/strings

<resources>

    ...
    <string name="highlight_title"><b>Some text</b></string>

</resources>


In the layout

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Alarm!"
    android:textSize="30sp"
    android:textStyle="bold" />

No hay comentarios:

Publicar un comentario