我该如何申请一个样式的Andr​​oid应用程序的所有按钮 [英] How do I apply a style to all buttons of an Android application

查看:140
本文介绍了我该如何申请一个样式的Andr​​oid应用程序的所有按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经应用到我的整个应用程序的样式:

I have a style applied to my whole application:

AndroidManifest.xml中:

AndroidManifest.xml:

<application android:theme="@style/ApplicationStyle" android:icon="@drawable/icon" android:label="@string/app_name">

和我styles.xml:

And in my styles.xml:

 <style name="ApplicationStyle" parent="android:Theme">
  <item name="android:button">@style/CKButton</item>
 </style>
 <style name="CKButton" parent="android:style/Widget.Button">
  <item name="android:textSize">19sp</item>
  <item name="android:layout_margin">0dip</item>
  <item name="android:background">#ff0000</item>
 </style>

但风格不会得到应用。

But the style doesn't get applied.

我很抱歉,如果我只是用了假名字在 ApplicationStyle - 项目,但我没有线索在哪里寻找的对象名称和简单的假设,即的android:按钮适用于所有的按钮

I'm sorry if I just used the false name in the ApplicationStyle - Item, but I have no clue where to look for the object names and simply assumed, that android:button applies to all buttons.

推荐答案

有关Android的风格,您引用preSET属性的Andr​​oid已经奠定了在的 R.attr 。在这种情况下,它看起来像你想引用<一个href="http://developer.android.com/intl/fr/reference/android/R.attr.html#buttonStyle"><$c$c>android:buttonStyle.我认为这会工作:

For Android styles, you reference the preset attributes that Android has laid out in R.attr. In this case, it looks like you want to to reference android:buttonStyle. I think this would work:

<style name="ApplicationStyle" parent="android:Theme">
  <item name="android:buttonStyle">@style/CKButton</item>
</style>

这篇关于我该如何申请一个样式的Andr​​oid应用程序的所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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