statelistdrawable

Error : <item> tag requires a 'drawable' attribute or child tag defining a drawable

点点圈 提交于 2019-12-28 05:48:19
问题 I created a state-list selector file item_bg_selector.xml in the drawable folder like this : <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/item_background_selected" /> <item android:state_focused="true" android:drawable="@drawable/item_background_selected" /> <item android:state_pressed="true" android:drawable="@drawable/item_background_selected" /> <item android:drawable="@android:color/transparent"/> <

Unexpected button padding on ICS

限于喜欢 提交于 2019-12-24 06:58:31
问题 I have a custom button with a state list drawable that has a tight layout with very little padding. This button looks great on MDPI and HDPI devices, but padding is all wrong on my Motorola Xoom (ICS, MDPI device). Modifying the 'padding' and 'margin' attributes does nothing. Anyone have any suggestions on what may be causing the unnecessary padding? I'm fairly confident that both the state list drawable and the 9patch drawables are fine (they render perfectly on other MDPI devices). Attached

StateListDrawable not working

自古美人都是妖i 提交于 2019-12-21 06:19:23
问题 I'm trying to programatically set a StateListDrawable as the background of my custom view for a library project. Here's what I'm doing: final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ActionBar); int firstColor = a.getColor( R.styleable.ActionBar_backgroundGradientFirstColor, 0xff000000); int secondColor = a .getColor(R.styleable.ActionBar_backgroundGradientSecondColor, 0xff000000); int textViewColor = a.getColor(R.styleable.ActionBar_titleColor, 0xffffffff); int

Android: Permanently elevate View

不打扰是莪最后的温柔 提交于 2019-12-11 11:46:09
问题 I have a RecyclerView , that has a RippleEffect as well as a StateListAnimator (which is shown below): anim_lift.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="true" android:state_pressed="true"> <set> <objectAnimator android:duration="@android:integer/config_shortAnimTime" android:propertyName="translationZ" android:valueTo="8dp" android:valueType="floatType"/> </set> </item> <item> <set>

StateListDrawable not working

…衆ロ難τιáo~ 提交于 2019-12-03 17:18:44
I'm trying to programatically set a StateListDrawable as the background of my custom view for a library project. Here's what I'm doing: final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ActionBar); int firstColor = a.getColor( R.styleable.ActionBar_backgroundGradientFirstColor, 0xff000000); int secondColor = a .getColor(R.styleable.ActionBar_backgroundGradientSecondColor, 0xff000000); int textViewColor = a.getColor(R.styleable.ActionBar_titleColor, 0xffffffff); int onClickColor = a.getColor( R.styleable.ActionBar_backgroundClickedColor, 0xff999999); a.recycle();

Custom Notification View

China☆狼群 提交于 2019-12-03 08:19:29
问题 I would like to create a notification icon view that looks similar to the Google+ app's notification. The difference will be that I need to be able to change the color at runtime where as the Google+ icons gray or red so I'm assuming they are using a StateListDrawable. What is the best approach for this? I'd prefer to have the rounded clipped corners and have the option to have a drawable inside. This custom view will be placed in the Action Bar as well. I still need the view to respond to

Custom Notification View

可紊 提交于 2019-12-02 22:14:21
I would like to create a notification icon view that looks similar to the Google+ app's notification. The difference will be that I need to be able to change the color at runtime where as the Google+ icons gray or red so I'm assuming they are using a StateListDrawable. What is the best approach for this? I'd prefer to have the rounded clipped corners and have the option to have a drawable inside. This custom view will be placed in the Action Bar as well. I still need the view to respond to android:background state list drawables so I can have the click and selected accordance working. This

Get specific drawable from state list drawable

℡╲_俬逩灬. 提交于 2019-11-30 19:35:59
I have a state list drawable, and i want to get a specific drawable from the state list drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:kplus="http://schemas.android.com/apk/res-auto"> <item kplus:key_type_space_alt="true" android:state_pressed="true" android:drawable="@drawable/space_1_pressed" /> <item kplus:key_type_space_alt="true" android:drawable="@drawable/space_1_normal" /> <!-- TopNav keys. --> <item kplus:key_type_topnav="true" android:state_pressed="true" android:drawable="@drawable/tab_down" /> <item kplus

Get specific drawable from state list drawable

我是研究僧i 提交于 2019-11-30 02:56:21
问题 I have a state list drawable, and i want to get a specific drawable from the state list drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:kplus="http://schemas.android.com/apk/res-auto"> <item kplus:key_type_space_alt="true" android:state_pressed="true" android:drawable="@drawable/space_1_pressed" /> <item kplus:key_type_space_alt="true" android:drawable="@drawable/space_1_normal" /> <!-- TopNav keys. --> <item kplus

Color State List not recognized in Shape Drawable

落花浮王杯 提交于 2019-11-27 02:50:27
问题 I define following drawable my_background_drawable.xml : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:gravity="center" android:shape="rectangle"> <solid android:color="@color/color_stateful" /> </shape> </item> <item android:drawable="@drawable/selector_png_drawable" /> </layer-list> And I also define following color state list resource color_stateful.xml : <?xml version="1.0" encoding="utf-8"?> <selector