2016-09-01 13 views
0

からは動作しません:書道フォントは、私が<a href="https://github.com/chrisjenx/Calligraphy" rel="nofollow">Calligraphy</a></p> <p>を使用するようにしてくださいこんにちは私は私の活動のこの持ってstyle.xml

@Override 
protected void attachBaseContext(Context newBase) { 
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); 
} 

を、私はこのレイアウトでフォントを使用したい(それはレイアウトですフラグメント用):

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:fontPatch="http://schemas.android.com/apk/res-auto" 
    style="@style/fragmentMainBackground" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:gravity="center_horizontal" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/grid_0" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/grid_0" 

tools:context=".app.mainscreen.MainActivity" 
tools:ignore="MissingPrefix"> 


    <TextView 
    android:id="@+id/statusTv" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="@style/fontDexlineProRegular"/> 

//... 

と私のスタイル:

<style name="fontDexlineProRegular" parent="android:TextAppearance"> 
    <item name="fontPath">fonts/DexlinePro-Regular.ttf</item> 
</style> 

これは機能しません。

が、私はこれを使用してみてください:フォントは、私は、スタイルからフォントを設定するにはどうすればよい

//... 
<TextView 
android:id="@+id/statusTv" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
fontPath="fonts/DexlinePro-Regular.ttf"/> 
//... 

に動作しますか? style.xmlの何が間違っていますか?

+0

どのようなエラーメッセージが表示されますか? – qantik

+0

エラーメッセージはありません。フォントのみが変更されません... –

+0

フォント名(およびすべての参考資料)を変更すると、次のようになります: 'フォント/ DexlineProBolt.otfからアセットを作成できません。正しいパスとファイル名が渡されていることを確認してください.'しかしフォントはあります。 –

答えて

0

これはCalligraphyConfig.initDefault(...と開始作業:/

0

資産フォルダ

注意にあなたのDexlinePro_Regular.ttfを入れて:私は追加のTextViewする... TTFファイルをundersore

を取ると、設定してください。..

TextView statusTv= (TextView) findViewById(R.id.statusTv); 
    Typeface font = Typeface.createFromAsset(getAssets(), "DexlinePro_Regular.ttf"); 
    statusTv.setTypeface(font); 
関連する問題

 関連する問題