我是靠谱客的博主 愉快音响,这篇文章主要介绍android应用添加字体,android中的自定义字体(适用于整个应用程序...,现在分享给大家,希望可以做个参考。

您可以使用字样为textview中的文本设置自定义字体.因此,每当需要textview的自定义字体时,都可以使用以下字体.

activity_main.xml中

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textColor="#FFF"

/>

编码:

public class MainActivity extends Activity {

private TextView text;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

text = (TextView) findViewById(R.id.text);

Button b= (Button) findViewById(R.id.button1);

b.setOnClickListener( new OnClickListener()

{

@Override

public void onClick(View v) {

text.setText("This is a custom toast");

Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/kn.ttf");

text.setTypeface(typeFace);

}

});

}

}

最后

以上就是愉快音响最近收集整理的关于android应用添加字体,android中的自定义字体(适用于整个应用程序...的全部内容,更多相关android应用添加字体,android中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(117)

评论列表共有 0 条评论

立即
投稿
返回
顶部