2015年7月11日 星期六

【Android】Android studio 如何新增drawable

如何在Android Studio 中 新增drawable


首先

右鍵點選drawable資料夾 --> new --> Image Asset





















然後

點選進入,並選擇你要新增的圖片檔案



















在drawable的資料夾就會新增你剛剛新增的圖檔了,並且會分別製成不同大小的圖檔,供你使用。


官方所製作的圖檔:
https://www.google.com/design/icons/index.html
官方提供製作圖檔的工具:
http://romannurik.github.io/AndroidAssetStudio/index.html

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