android – ICS-looking按钮:我必须在ICS SDK中选择哪个drawable?

我刚看了一下Ice Cream Sandwich源代码,因为我试图将Holo Theme移植到所有4.0之前的设备上.

我使用了很多有用的工具:

操作栏:ActionBarSherlock

ICS背景:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:angle="270"
    android:startColor="#ff020202"
    android:endColor="#ff272D33d"
    android:type="linear" />
</shape>

直到现在,一切都很棒!!!

我现在正在尝试创建一个按钮,但找不到正确的背景:

以下来源:https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/btn_default.xml

我试过这个:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/btn_default_normal" />
<item android:state_window_focused="false" android:state_enabled="false"
    android:drawable="@drawable/btn_default_normal_disable" />
<item android:state_pressed="true" 
    android:drawable="@drawable/btn_default_pressed" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/btn_default_selected" />
<item android:state_enabled="true"
    android:drawable="@drawable/btn_default_normal" />
<item android:state_focused="true"
    android:drawable="@drawable/btn_default_normal_disable_focused" />
<item
     android:drawable="@drawable/btn_default_normal_disable" />

我将每个.9.png文件复制到我的drawable文件夹中.

但不幸的是,所有这些drawable似乎相当白,我无法得到类似于这个按钮的东西:

以下是所有资源:

btn_default_normal_holo_dark.9.png

btn_default_normal_holo_light.9.png

btn_default_normal.9.png

解决方法

我不得不选择Holo Dark主题
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/btn_default_normal_holo_dark" android:state_enabled="true" android:state_window_focused="false"/>
    <item android:drawable="@drawable/btn_default_disabled_holo_dark" android:state_enabled="false" android:state_window_focused="false"/>
    <item android:drawable="@drawable/btn_default_pressed_holo_dark" android:state_pressed="true"/>
    <item android:drawable="@drawable/btn_default_focused_holo_dark" android:state_enabled="true" android:state_focused="true"/>
    <item android:drawable="@drawable/btn_default_normal_holo_dark" android:state_enabled="true"/>
    <item android:drawable="@drawable/btn_default_disabled_focused_holo_dark" android:state_focused="true"/>
    <item android:drawable="@drawable/btn_default_disabled_holo_dark"/>

</selector>

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...