Code example for Context

Methods: getResources

	 * Convert from device-independent-pixels to pixels for use in custom view drawing, as 
	 * used throughout Android.  
	 * See: (Romain Guy's comment)   
	public static int convertDPsToPixels(Context context, final int dps) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (dps * scale + 0.5f);
     * Sets the alpha of a view in a manner that is safe to use before API version 11. 
     * If alpha isn't supported, just make the view invisible if the alpha is so low 
     * that it may as well be. 
    public static void setViewAlpha(View v, float alpha) {
        v.setVisibility((alpha > 0.001) ? View.VISIBLE : View.INVISIBLE);
Connect your IDE to all the code out there  Get Codota for Java