So you have some color like R.color.black and you want to add transparency to it. Rather than storing that value inside the colors.xml file, you can do so programmatically.

If you are using the support library, you can use ColorUtils.setAlphaComponent(color, alpha) method.

If you want using basic Java, do it like this: (color & 0x00ffffff) | (alpha << 24). Remember, the color value is not R.color.mycolor. I use the Compat library all the time so I convert the R.color.mycolor variable to ContextCompat.getColor(context, R.color.mycolor) then pass that to the formula above or the setAlphaComponent() parameter.

The only way to have a custom button like the zoom buttons in Android map is to make one of your own. The way I did this is to have an XML drawable assigned to the ImageButton. It is pretty simple.

Then assign this as background to the ImageButton widget. Your image should be assigned to the source attribute.

That’s it!

Forget trying to familiarize those keytool command options. An easier way is to call a method to output the keyhash of the keystore being used in the app.

This is a method from JavaTechIG. Pretty slick.

Related Posts Plugin for WordPress, Blogger...