2015年7月7日 星期二

【Android】Android Studio assets資料夾& fonts 新增外部字型


這次要解決一個簡單的小問題,以前使用Eclipce時有一個assets資料夾,
但使用Android studio時要如何建立這個資料夾?

並且新增完assets資料夾後新增外部字型。


首先

assets資料夾在Android studio中以Android 專案顯示方式來看,是與Manifiest & Java 在同一層


所以

我們直接於 app 右鍵-->new --> folder --> assets 
就能夠找到。


建立起來之後就能在新增fonts資料夾來使用外部字型


將字型檔案放入後就能夠以下面的code來使用外部字型

TextView WebTitleText;
WebTitleText = (TextView) Custom.findViewById(R.id.WebTitleText);
//設定字型
Typeface face = Typeface.createFromAsset(FragmentContext.getAssets(),"fonts/Roboto-Bold.ttf");
WebTitleText.setTypeface(face);


參考網址:
http://stackoverflow.com/questions/18302603/where-to-place-assets-folder-in-android-studio

沒有留言:

張貼留言