Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

java - Location of Holo focused Button drawable

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

yourandroidsdkrootfolderpathplatformsandroid-11data esdrawable
(ex:D:androidplatformsandroid-11data esdrawable)

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" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...