gpt4 book ai didi

android - 自定义属性在 HoloEverywhere 中不起作用

转载 作者:行者123 更新时间:2023-11-30 03:37:39 27 4
gpt4 key购买 nike

我在我的应用程序中使用了 HoloEverywhere 库,为了应用主题中的字体,我向 TextView 样式添加了一个新的自定义属性 ttfName,并在 org.holoeverywhere.widget.TextView 的构造函数中进行了一些必要的更改,如下所示;

if (a.hasValue(R.styleable.TextView_ttfName)) {
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/" +
a.getString(R.styleable.TextView_ttfName)));
}

另外,声明的样式和主题如下;

<style name="AppTheme" parent="@style/Holo.Theme.Light.DarkActionBar">                
<item name="android:textViewStyle">@style/Widget.ApplicationTheme.TextView</item
</style>

<style name="Widget.ApplicationTheme.TextView" parent="@style/Holo.TextView">
<item name="ttfName">@string/app_font_roboto_light</item>
<item name="android:textSize">@dimen/app_dimen_default_text_size</item>
</style>

并且添加的ttfName属性如下;

...
<attr name="ttfName" format="string" />
...
...
<declare-styleable name="TextView">
<attr name="android:text" />
<attr name="android:textAllCaps" />
<attr name="textAllCaps" />
<attr name="ttfName" />
</declare-styleable>
...

现在,当我将 AppTheme 应用于我的应用程序时,仅当 android 版本 > 4.0(尚未检查 3.0)时才会应用字体。但是在 android 2.3 版本上,字体没有被应用..

谁能帮我弄清楚这里出了什么问题?

提前致谢。

最佳答案

它是不适用于 preHC 机器人上的 Holoeverywhere 的字体,preHC 上的 FontLoader 在所有 TextView 中加载 roboto 字体。

要应用字体,请查看类 org.holoeverywhere.FontLoaderFontLoader#apply(View) 方法。

关于android - 自定义属性在 HoloEverywhere 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16386861/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com