我该如何申请一个样式的Andr​​oid应用程序的所有按钮我该、应用程序、样式、按钮

2023-09-11 20:17:21 作者:`活出自己的精彩.℡

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

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 。在这种情况下,它看起来像你想引用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>