自定义Holo按钮

And*_*uin 5 android button

我尝试过搜索和使用其他人在这里发布的自定义选择器,使用设置的颜色过滤器和其他各种东西.我认为我完全错了,因为在完全诚实的情况下,我对刚刚开始开发的设计并不满意,但我仍然不认为按照我所看到的那样做我想做的事情会很复杂:

我开发了一个froyo和up的应用程序.我希望按钮的背景颜色为全局绿色和全息橙色,如Android开发人员网站上的样本.这就是我想要与众不同的一切.当按下holo上的按钮或标准按钮onpress等时,我希望标准的蓝色突出显示在froyo,gingerbread等中的行为.

我真的很感激任何指导.提前谢谢你们!

Dal*_*mas 7

编辑:

有一种更容易的方式来改变全息主题的颜色.本网站将为您完成:

http://android-holo-colors.com


自定义全息按钮的唯一方法是使用Photoshop等图像编辑器编辑按钮绘图.方法如下:

  • 打开platforms/android-17/data/resSDK目录中的文件夹,找到可绘制文件夹中的全息按钮(以它们开头btn_default_holo_...).
  • 使用图像编辑器打开它们,只需更改颜色(色调/饱和度)即可匹配所需的颜色.有3或4个不同的抽屉,每个按钮状态一个.
  • 将它们保存在应用程序的相应drawable文件夹中.你必须为你要处理的每个屏幕密度做到这一点(mdpi,hdpi,xhdpi通常就足够了).

我还没有测试过,但仅仅编辑xhdpi按钮就足够了.它们将缩小到较低的密度.

自定义每个drawable后,必须创建一个用作自定义按钮的选择器.以下是我在其中一个应用中使用的选择器示例,用于创建绿色全息按钮:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_window_focused="false" android:state_enabled="true"
          android:drawable="@drawable/__btn_green_normal_holo_light"/>
    <item android:state_window_focused="false" android:state_enabled="false"
          android:drawable="@drawable/__btn_default_disabled_holo_light"/>
    <item android:state_pressed="true"
          android:drawable="@drawable/__btn_default_pressed_holo_light"/>
    <item android:state_focused="true" android:state_enabled="true"
          android:drawable="@drawable/__btn_default_focused_holo_light"/>
    <item android:state_enabled="true"
          android:drawable="@drawable/__btn_green_normal_holo_light"/>
    <item android:state_focused="true"
          android:drawable="@drawable/__btn_default_disabled_focused_holo_light"/>
    <item
          android:drawable="@drawable/__btn_default_disabled_holo_light"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

这是一个修改过的绿色全息按钮可绘制的示例.如果你感兴趣,你可以检查我项目的其他drawables,我做你想做的事情(我也有一个红色按钮).