I've got the crouton library ( https://github.com/keyboardsurfer/Crouton ) working with the default layout for notifications. I would like to use a custom layout xml file for the notifications so I could set a different typeface to the TextView
to match the rest of my application. I have extended a TextView
to get the custom typeface working.
Browsing the source for the library, I found a couple of methods that will probably help me:
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);
}
But I'm struggling to find good example on how to use custom layouts for crouton messages and how I would set the text/message style for them (I have defined some custom styles using Style.Builder()
).
The custom layout I want to use is:
<?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>
Can someone point me in the right direction?
You can a custom Style
that uses the resourceId
of your text appearance via Style.Builder.setTextAppearance(...)
.
This takes a reference from your styles.xml
and uses it within the internal TextView
of the Crouton
.
Then you can call Crouton.makeText
or Crouton.showText
with your custom Style.