How to make android:drawable/btn_default transparent
I am using btn_default for my background of a spinner and that works nicely. I would now like to make the btn_default transparent. I have read about maybe using nine patch to make my own button based on btn_default but I can't find btn_default.png anywhere. I am not sure if this is how to do it so i开发者_C百科f someone explain how to make the btn_default transparent it would be much appreciated.
The image you are looking for is in the android sdk folder, i.e.: android-sdk/platforms/android-1.6_r02-macosx/data/res/drawable/btn_default.xml on my mac. Actually it's a statelist drawable that defines what image to use for which button state.
You can copy btn_default.xml and the corresponding images (btn_default_normal.9.png, ...) into your projects drawable folder and edit the png, and make the buttons use your custom btn_default.xml as background. If you copy and change the images you have to obey the License (I think it's the Apache 2).
EDIT
There is no image "btn_default.png", just a statelist drawable "btn_default.xml". It lists the images for the different states of the button. Those images are name: btn_default_normal.9.png, btn_default_selected.9.png, btn_default_pressed.9.png, etc.
To find certain images you have to work your way up trough the platform specific res folders. The resources will be in the platform folder of the android version they were introduced. I.e. I can find btn_default_normal.9.png in android-1.6_r02-macosx/data/res/drawable and in android-1.5/data/res/drawable, but not in android-8/data/res/drawable. This means 1.5 inroduced the resource, 1.6 changed the resource somehow and android-8 is using this resource from an earlier version (maybe 1.6).
Not all resources are public, thats the reason for the error "Error: Resource is not public. (at 'background' with value '@android:drawable/btn_default_transparent')". To use btn_default_transparent.xml, copy btn_default_transparent and the images it references into your projects resfolder.
here is what I ended doing which was to modify the btn_default_normal and removed the background and saved it as btn_default_normal_invisible. transparency was probably a poor explanation because i really just wanted it all gone so the spinner would look like othe text labels that were not spinners
<Spinner
android:id="@+id/m1_ss_spinner"
android:background="@drawable/btn_default_normal_invisible"
/>
精彩评论