Change int color opacity in java/android
I am trying to change the opacity of a color that I get of my theme with the next code: TypedValue typedValueDrawerSelected = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, typedValueDrawerSelected, true); int colorDrawerItemSelected = typedValueDrawerSelected.data; I want that the colorDrawerItemSelected keeps the same color, buth its alpha should be 25%. I found some solutions getting the rgb color from the imageView, but I havent imageView. Thank you for your time. Wouldn't it be sufficient? colorDrawerItemSelected = (colorDrawerItemSelected & 0x00FFFFFF) | 0x40000000;