简体   繁体   English

如何在android中为textview设置telugu字体?

[英]how to set the telugu font for textview in android?

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);
    }
}

Please try it . 请尝试一下。

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);
}

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM