Android: using framework drawables in custom button selector
I'd need to create custom button, but I'd want to use framework's default button highlight colors for pressed and focused states. My question is similar to this one.
My selector code looks like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@android:drawable/grid_selector_background_pressed"/>
<item android:state_focused="true" android:drawable="@android:drawable/grid_selector_background_focus"/>
<item>
<shape>
<solid android:color="#EAEAEA"/>
开发者_开发技巧 <stroke
android:width="0dp"
android:color="#A0A0A0"/>
<corners
android:radius="0dp"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"/>
</shape>
</item>
</selector>
So I'm basically trying to reference drawables grid_selector_background_pressed and grid_selector_background_focus. The dev environment does find those drawables as it auto-suggests them upon typing, but then gives "Resource is not public" when compiling.
Is there a way to use the above mentioned framework drawables?
Pom
You can go into your android-sdk folder, pick your platform, and copy the drawables from the appropriate res/drawable folder into your local drawable folder, and reference them from there.
精彩评论