【发布时间】:2014-06-20 22:05:43
【问题描述】:
在我的项目中,我为按钮使用特殊字体。所以我添加了PixlUI 库,这样我就可以在 xml 中设置字体了。
<com.neopixl.pixlui.components.button.Button
android:id="@+id/btn_login"
style="@style/custom_button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login"
pixlui:typeface="AvenirNextCondensed-Regular.ttf" />
<com.neopixl.pixlui.components.button.Button
android:id="@+id/btn_register"
style="@style/custom_button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/make_new_profile"
pixlui:typeface="AvenirNextCondensed-Regular.ttf" />
<com.neopixl.pixlui.components.button.Button
android:id="@+id/btn_broker_register"
style="@style/custom_button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/make_new_profile_broker"
pixlui:typeface="AvenirNextCondensed-Regular.ttf" />
这些是我的按钮,因为它们都具有相同的字体,我想在“custom_button_style”中包含该字体
这是我的自定义样式:
<style name="custom_button_style" parent="@android:style/Widget.Button">
<item name="android:textSize">@dimen/hello_medium_fontsize</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:background">@drawable/custom_btn_background</item>
<item name="android:layout_marginBottom">@dimen/login_button_margin</item>
</style>
如何添加
pixlui:字体
这种风格?
【问题讨论】:
-
<item name="pixlui:typeface">AvenirNextCondensed-Regular.ttf</item>有效吗? -
不,我收到错误消息“找不到与给定名称匹配的资源:attr 'pixlui:typeface'。我必须改变父母吗?
-
您是否将此属性设置为您的父布局?:xmlns:pixlui="schemas.android.com/apk/com.neopixl.pixlui"。通常,你可以使用 pixlui 属性
-
@Opiatefuchs 我已将该属性设置为我的父布局,并且在我的布局中使用该属性没有问题。但我想在我的样式中包含该属性,以避免每个按钮都包含它。
-
这个有运气吗?