Action Bar(title文字大小問題 基本運用)
一丶任務
(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)可用有關且有助於理解的文章
連結:http://www.cnblogs.com/angeldevil/p/3836214.html(2)類似問題且已解決文章
【已解決】Android中選單的字型太小了:設定actionbar中menu的text的size
連結:http://www.tuicool.com/articles/ue6Nbi(3)Action Bar加強
這一篇寫得很詳細,基本概括了Action Bar常用功能
三丶其他知識
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);