import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface tf = Typeface.createFromAsset(getAssets(),"Tikkana.ttf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setText("ప్రముఖులు అభిప్రాయాలు");
tv.setTypeface(tf);
}
}
答案 0 :(得分:0)
请试试。
public class CustomTextView extends TextView
{
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomTextView(Context context) {
super(context);
init();
}
private void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"Helvetica.ttf");
setTypeface(tf);
}
}