我想为我的“按钮”文本和“编辑文本框”文本设置不同的字体样式,例如新罗马,卡里布利,坎布里亚和乔治亚。如何设置不同的字体,例如要将登录按钮文本更改为Calibri字体的示例。我不知道如何从MS Office或字体文件设置或导入字体。请建议我,谢谢..
我的XML代码在这里
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint=" User Name " />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint=" Password "
android:fontFamily="Tekton Pro Ext"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="Tekton Pro Ext"
android:text=" Login " />
</LinearLayout>
布局
您需要在项目中的Assets文件夹下创建fonts文件夹,然后将TTF放入其中,在主菜单或活动中,您可以将字体设置为
TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/mytruetypefont.ttf");
myTextView.setTypeface(typeFace);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句