Skip to content Skip to sidebar Skip to footer

Android Imageview - How To Not Make Imageview Tinted

I have the following layout.xml:

Solution 1:

It turns out that the image is tinted because I call the setAlpha for the parent layout:

layout.setAlpha(0.5f);

However, it is required for me to set the 50% opacity for the parent layout. So I use the below way to set Alpha and RGB for the background color of parent layout and it works: background color of the parent layout is set without tinting the child's image.

LinearLayoutlayout= (LinearLayout) view.findViewById(R.id.layout);
layout.setBackgroundColor(BitmapDrawableUtility. getColorByOpacityPercentage(calculateOpacity(Color.parseColor("#727272"), 50));


publicstaticintgetColorByOpacityPercentage(int color, double percentage) {
    inttransparency= (int) Math.round((percentage / 100.0) * 255.0);
    return Color.argb(transparency, Color.red(color), Color.green(color), Color.blue(color));
}

Post a Comment for "Android Imageview - How To Not Make Imageview Tinted"