3

我的应用程序中有以下样式。

  <style name="BtnPressed">
      <item name="android:background">@drawable/btn_default</item>
  </style>

现在我想将它应用于ImageButtons我的应用程序中的所有内容。我尝试使用这个问题中提到的解决方案,但没有奏效。我正在使用 API-7。

4

2 回答 2

8

将您的 BtnPressed 样式更改为:

<style name="BtnPressedStyle" parent="Widget.ImageButton">
  <item name="android:background">@drawable/btn_default</item>
</style>

定义应用程序范围的主题/样式:

<style name="MyTheme" parent="android:Theme">
   <item name="android:imageButtonStyle">@style/BtnPressedStyle</item>
</style>

然后将其应用于清单的应用程序标签:

<application theme="@style/MyTheme" ... />

让我知道这是否可行,我从覆盖应用程序范围按钮样式的代码中对其进行了修改,但 ImageButton 应该也可以正常工作。

于 2012-07-08T07:11:03.620 回答
-5

您还可以在 IDE 中花费大约 5 分钟(notepad++ 会这样做)并搜索和替换 xmls 上的 ImageView ,以及代码中生成的图像视图的小片段。我不认为这是错误的,并且会帮助您维护应用程序。

于 2012-07-08T06:03:24.543 回答