回答
呀,爲什麼不,你可以得到的Roboto字體:
比方說,你想改變文本視圖的字體:
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/Roboto-Black.ttf");
TextView tv = (TextView) findViewById(R.id.FontTextView);
tv.setTypeface(tf);
試試這個鏈接http://www.barebonescoder.com/2010/05/android-development-using-custom-fonts/
設置你的目標,以襯線控制的字體屬性和... ...我建議使用TTF字體文件,它已經爲我工作在過去
也可以嘗試這些鏈接
http://techdroid.kbeanie.com/2011/04/using-custom-fonts-on-android.html
要以XML格式設置字體的工作量要稍微多些,但其優點是能夠在XML佈局編輯器的Eclipse ADT的圖形佈局選項卡內預覽字體。再次,首先將您的自定義字體.ttf文件包含在應用程序的資產文件夾中。
創建一個自定義的TextView類:
public class TypefacedTextView extends TextView
{
public TypefacedTextView(Context context, AttributeSet attrs)
{
super(context, attrs);
// Typeface.createFromAsset doesn't work in the layout editor. Skipping ...
if (isInEditMode())
{
return;
}
TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TypefacedTextView);
String fontName = styledAttrs.getString(R.styleable.TypefacedTextView_typeface);
styledAttrs.recycle();
if (fontName != null)
{
Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontName);
setTypeface(typeface);
}
}
}
我們在您的XML佈局這一習俗TypefacedTextView只需添加您的XML命名空間屬性Android的XML命名空間屬性如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:your_namespace="http://schemas.android.com/apk/res/com.example.app"
... />
和使用您的TypefacedTextView與XML中的普通TextView一樣,但帶有自己的自定義標籤,記住要設置字體:
<com.example.app.TypefacedTextView
android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="48dp"
android:textColor="#FF787878"
your_namespace:typeface="Roboto-Regular.ttf" />
查看我的博客文章的詳細信息: http://polwarthlimited.com/2013/05/android-typefaces-including-a-custom-font/
404上的鏈接在答案中 – harmanjd
- 1. 整個應用程序的Roboto字體
- 2. Android Black Roboto字體樣式
- 3. Roboto字體爲Android 4+?
- 4. 在Android Studio中爲我的應用程序設置Roboto爲我的全球字體
- 5. React webpack應用程序未載入Roboto字體
- 6. 如何爲整個應用程序設置Roboto字體?
- 7. Roboto ios的字體
- 8. 在Android中指定一個Roboto字體
- 9. 如何在我的android應用程序中使用Roboto字體作爲所有視圖?
- 10. 用roboto替換Lato字體
- 11. 導入資產/字體文件夾中的roboto字體後,我的應用程序滾動很糟糕
- 12. 在最低API級別的應用中使用Roboto字體14
- 13. 如何使用的Roboto字體在Android項目
- 14. 我的Android應用程序在我的Android應用程序
- 15. Android - 應用程序中的字體
- 16. 使用早期設備的Roboto字體
- 17. Roboto字體大膽與Firefox
- 18. 在TextView中設置的Roboto字體 - XML
- 19. Roboto在chrome中的字體問題
- 20. 在android應用程序中修復字體和字體大小
- 21. Android應用程序字體渲染
- 22. 將Google字體集成到我的Android應用程序中
- 23. 從Roboto經常更改字體到Roboto濃縮
- 24. 字體家族Roboto光線和粗體反應原生
- 25. 在android應用程序的webview中的海關字體
- 26. 如何在我的Android應用程序中使用「字體樣式」?
- 27. Delphi如何在Android上使用自定義字體我的應用程序?
- 28. 在WebView中爲我的Android應用程序使用自定義(unicode)字體
- 29. 在我的Android應用程序中使用Maps應用程序
- 30. roboto-android和roboto-unhinted有什麼區別?
有沒有在XML本身設置這種字體屬性的方法?或者更簡單地說,在AndroidManifest.xml本身中使用整個應用程序? – Rahim
我沒有找到任何方法來做到這一點,所以我結束了這個http://stackoverflow.com/questions/9797872/use-roboto-font-for-earlier-devices/10563831#10563831 – Arnaud