1
我有面包房圖書館(https://github.com/keyboardsurfer/Crouton)使用通知的默認佈局。我想爲通知使用自定義佈局xml文件,所以我可以設置不同的字體到TextView
以匹配我的應用程序的其餘部分。我已經擴展了TextView
以獲得定製字體的工作。使用自定義佈局的麪包房圖書館
瀏覽源庫,我發現一對夫婦的方法,可能會幫助我:
public static Crouton make(Activity activity, View customView, ViewGroup viewGroup) {
return new Crouton(activity, customView, viewGroup);
}
public static Crouton make(Activity activity, View customView) {
return new Crouton(activity, customView);
}
但我在努力尋找如何使用自定義佈局crouton消息以及如何很好的例子我會爲他們設置文本/消息樣式(我已經使用Style.Builder()
定義了一些自定義樣式)。
自定義佈局我想用的是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/uk.co.volume.pinkmothballs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.myapp.ui.views.TypefacedTextView
android:id="@+id/crouton_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:gravity="center"
/>
</RelativeLayout>
有人能指出我在正確的方向?
感謝您的回答,但我不認爲我可以使用'setTextAppearance',因爲我通過聲明一個'Typeface'並使用自定義'TextView'來設置非android系統字體。我還能嘗試什麼? – boz 2013-03-05 12:23:58
擴展庫永遠是可能的。我喜歡乾淨的拉取請求。 ;-)另外,你可以用你自己的'TypefacedTextView'替換'Crouton'的'TextView'成員。 – keyboardsurfer 2013-03-05 12:30:31
謝謝,我可能不得不在'Crouton'庫中替換幾行代碼,並以這種方式添加我的自定義字體。 – boz 2013-03-05 14:01:14