您的位置:首页 > 其它

Action Bar(title文字大小问题 基本运用)

2016-03-23 21:19 369 查看
本文出自:http://blog.csdn.net/dt235201314/article/details/50966456

一丶任务






(1)找到menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/loginId"
android:textColor="@color/txt_white_color"
android:typeface="serif"
android:title="@string/login_name"
android:showAsAction="withText|ifRoom"/>

</menu>

添加textSize属性发现并没什么用

(2)找到java代码对应部分,发现并没用修改文字大小的方法,改来改去行不通

二丶百度

(1)可用有关且有助于理解的文章


自定义ActionBar标题与菜单中的文字样式

链接:http://www.cnblogs.com/angeldevil/p/3836214.html

(2)类似问题且已解决文章


【已解决】Android中菜单的字体太小了:设置actionbar中menu的text的size

链接:http://www.tuicool.com/articles/ue6Nbi

(3)Action Bar加强

Android Action Bar 详解篇

链接:http://blog.csdn.net/yuxlong2010/article/details/9299507

这一篇写得很详细,基本概括了Action Bar常用功能

三丶其他知识

Android中通过typeface设置字体


Android系统默认支持三种字体,分别为:sans”, “serif”, “monospace",除此之外还可以使用其他字体文件(*.ttf)

方法一:XML中使用android默认字体

<!--  使用默认的sans字体-->

        <TextView    Android:id="@+id/sans"

                   Android:text="Hello,World"

                   Android:typeface="sans"

                   Android:textSize="20sp" />

<!--  使用默认的serifs字体-->

        <TextView   Android:id="@+id/serif"

                   Android:text="Hello,World"

                   Android:typeface="serif"

                   Android:textSize="20sp" />

<!--  使用默认的monospace字体-->

        <TextView   Android:id="@+id/monospace"

                   Android:text="Hello,World"

                   Android:typeface="monospace"

                   Android:textSize="20sp" />

方法二:在Android中可以引入其他字体,首先要将字体文件保存在assets/fonts/目录下

1.  <!--  这里没有设定字体,将在Java代码中设定-->

<TextView   Android:id="@+id/custom"

                   Android:text="Hello,World"

                    Android:textSize="20sp" />

2.  java程序中引入其他字体关键代码

  //得到TextView控件对象

        TextView textView =(TextView)findViewById(R.id.custom);

  //将字体文件保存在assets/fonts/目录下,创建Typeface对象

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

  //使用字体

  textView.setTypeface(typeFace);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: