Location of Holo focused Button drawable

天涯浪子 提交于 2019-12-12 02:35:02

问题


Does anyone know what is the location of Holo theme focused button drawable?
I would like to set it to my View on some event, but I can't find it.


回答1:


1.first locate following location in your android sdk platforms folder -

yourandroidsdkrootfolderpath\platforms\android-11\data\res\drawable
(ex:D:\android\platforms\android-11\data\res\drawable)

2.find the xml file on folder named as btn_default_holo_dark.xml and it's contain like below code:

 <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_holo_dark" />
    <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/btn_default_normal_disable_holo_dark" />
    <item android:state_pressed="true" 
        android:drawable="@drawable/btn_default_pressed_holo_dark" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_default_selected_holo_dark" />
    <item android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal_holo_dark" />
    <item android:state_focused="true"
        android:drawable="@drawable/btn_default_normal_disable_focused_holo_dark" />
    <item
         android:drawable="@drawable/btn_default_normal_disable_holo_dark" />
</selector>

3.copy xml to your project drawable folder

4.copy drawable-hdpi,drawable-ldpi,drawable-mdpi images mentioned above xml like

btn_default_normal,btn_default_normal_disable,btn_default_pressed,btn_default_selected,btn_default_normal,btn_default_normal_disable_focused,btn_default_normal_disable

5.add style to your style.xml file like below

<style name="Custombutton" parent="Widget.Button">
        <item name="android:background">@android:drawable/btn_default_holo_dark</item>
        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
        <item name="android:textColor">@android:color/primary_text_holo_dark</item>
        <item name="android:minHeight">48dip</item>
        <item name="android:minWidth">64dip</item>
    </style>

6.apply your button style like below code:

 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    style="@style/Custombutton"
    android:layout_height="wrap_content"
    android:text="Button" />



回答2:


Hdpi versions:

/<android sdk path>/platforms/android-15/data/res/drawable-hdpi/btn_default_disabled_holo.9.png
/<android sdk path>/platforms/android-15/data/res/drawable-hdpi/btn_default_focused_holo.9.png
/<android sdk path>/platforms/android-15/data/res/drawable-hdpi/btn_default_normal_holo.9.png
/<android sdk path>/platforms/android-15/data/res/drawable-hdpi/btn_default_pressed_holo.9.png

other resolutions are in drawable-ldpi,drawable-mdpi,drawable-xhdpi directories.



来源:https://stackoverflow.com/questions/17440993/location-of-holo-focused-button-drawable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!