KB-20071223-038
From Triled Wiki
- Status: opened
- author: Pierre Neihouser
- link: http://groups.google.com/group/android-developers/msg/0dbfbc857d01bc4e
- Description: TextView.setTypeFace(TypeFace) is not working for italic style.
- Confirmed on: Android SDK versions: m3-rc22a
- Steps to reproduce:
java code example:
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class BufferTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.tv);
Typeface tf = Typeface.create((Typeface)null, Typeface.ITALIC);
tv.setTypeface(tf);
// or just
// tv.setTypeface(Typeface.DEFAULT_ITALIC);
}
};
layout example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
id="@+id/ll">
<TextView id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/tv"
android:textAlign="end"
android:padding="3dip" />
</LinearLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="tv">Piza's Tower has more italic style.</string>
</resources>
expected: italic style of this string.
But no style is applied to string, contained in TextView. Same problem exists for Typeface.DEFAULT_BOLD_ITALIC (text is bold, but not italic).
However, if you specify android:textStyle="italic" attribute for TextView tag in layout file, it'll be shown as italic, you also may make it bold at runtime.
