2017-08-02 5 views
0

私はこのページを読んでいますhttps://developer.android.com/preview/features/fonts-in-xml.html textviewは大丈夫ですが、textclockは動作しません。android textclock set fontfamily not work

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.hellokai.myapplication.MainActivity"> 

    <TextClock 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fontFamily="@font/oswald_stencbab" 
     android:format12Hour="hh:mm" 
     android:format24Hour="hh:mm" 
     android:textSize="60dp" 
     android:text="hello" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 
    <TextView 
     android:textSize="60dp" 
     android:text="@string/app_name" 
     android:fontFamily="@font/oswald_stencbab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</android.support.constraint.ConstraintLayout> 

enter image description here

にはどうすればいいのTextViewのようなTextClock作業を行うことができますか?

私はTextClockをウィジェットに書きますが、remoteviewはTextClockインスタンスを取得できません。私はTextClockフォントを変更しますが、私はそれを変更する方法を知らない。

誰かがこの問題を解決するのに役立ちます。

答えて

0

フォントをassets/fontsフォルダに保存しました。私は次のようにします。

Typeface typeFaceBlack = Typeface.createFromAsset(context.getAssets(), "fonts/Font.otf"); 
textClockID.setTypeface(typeFaceBlack);