使用自定义布局的crouton库 [英] Using custom layouts for the crouton library

查看:230
本文介绍了使用自定义布局的crouton库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了crouton库( https://github.com/keyboardsurfer/Crouton )与通知的默认布局工作。我想用一个自定义布局的XML文件通知,所以我可以设置不同的字体在的TextView 我的应用程序的其他部分相匹配。我纷纷伸出的TextView 来获取自定义字体工作。

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);
}

但我在努力寻找如何使用crouton消息自定义布局好榜样,我怎么会为他们设置的文本/消息样式(我已经定义使用​​一些自定义样式 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?

推荐答案

您可以使用自定义风格 RESOURCEID 通过 Style.Builder.setTextAppearance文本外观(...)

You can a custom Style that uses the resourceId of your text appearance via Style.Builder.setTextAppearance(...).

这需要从你的 styles.xml 参考,使用它的内部的的TextView 的<$ C之内$ C> Crouton 。

This takes a reference from your styles.xml and uses it within the internal TextView of the Crouton.

然后就可以调用 Crouton.makeText Crouton.showText 您的自定义样式。

Then you can call Crouton.makeText or Crouton.showText with your custom Style.

这篇关于使用自定义布局的crouton库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆