Android: failed to convert @drawable/picture into a drawable
Restart Eclipse (unfortunately) and the problem will go away.
Restart Eclipse (unfortunately) and the problem will go away.
As far as I’ve been able to find (I’ve tried doing something similar myself), there’s no way to modify a single state after the StateListDrawable has already been defined. You can, however, define a NEW one through code: StateListDrawable states = new StateListDrawable(); states.addState(new int[] {android.R.attr.state_pressed}, getResources().getDrawable(R.drawable.pressed)); states.addState(new int[] {android.R.attr.state_focused}, getResources().getDrawable(R.drawable.focused)); states.addState(new int[] { }, … Read more
This is what I use for my game. This is the compilation of various part found on various articles on websites. Credits goes to the original author from the @see links. Note that a lot more can be done with color matrices. Including inverting, etc… public class ColorFilterGenerator { /** * Creates a HUE ajustment … Read more
Use the <shape> tag to create a drawable in XML with rounded corners. (You can do other stuff with the shape tag like define a color gradient as well). Here’s a copy of a XML file I’m using in one of my apps to create a drawable with a white background, black border and rounded … Read more
Drawable d = getResources().getDrawable(android.R.drawable.ic_dialog_email); ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(d);
Try giving these values: <corners android:topLeftRadius=”6dp” android:topRightRadius=”6dp” android:bottomLeftRadius=”0.1dp” android:bottomRightRadius=”0.1dp”/> Note that I have changed 0dp to 0.1dp. EDIT: See Aleks G comment below for a cleaner version
Disclaimer This answer is from 2013 and is seriously outdated. As of Android 3.2 there are now 6 groups of screen density. This answer will be updated as soon as I am able, but with no ETA. Refer to the official documentation for all the densities at the moment (although information on specific pixel sizes … Read more
It’s deprecated but it still works so you could just use it. But if you want to be completly correct, just for the completeness of it… You’d do something like following: int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { setBackgroundDrawable(); } else { setBackground(); } For this to work you need to set buildTarget api … Read more
Your Activity should have the method getResources. Do: Drawable myIcon = getResources().getDrawable( R.drawable.icon ); As of API version 21 this method is deprecated and can be replaced with: Drawable myIcon = AppCompatResources.getDrawable(context, R.drawable.icon); If you need to specify a custom theme, the following will apply it, but only if API is version 21 or greater: … Read more
layout.setBackgroundResource(R.drawable.ready); is correct. Another way to achieve it is to use the following: final int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { layout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ready) ); } else { layout.setBackground(ContextCompat.getDrawable(context, R.drawable.ready)); } But I think the problem occur because you are trying to load big images. Here is a good tutorial how to load large bitmaps. … Read more