Question

ImageView with a transparent overlay

I have a tablelayout with two rows each consisting of two imageview. I want to achieve result as below. I have tried few solutions mentioned in stackoverflow but somehow I have not found a way to achieve this. Each imageview is looks as below

<ImageView
                android:id="@+id/imageViewY"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="@drawable/cell_border"
                android:clickable="true"
                android:padding="2dp"
                android:src="@drawable/letter_y" />

If you have any idea or solution to achieve this , i would like to request for your help. Thanks in advance.

Was it helpful?

Solution

use transparent color #11000000 as background of imageview Here 11 is a Transparency Value of color 000000(means Black color)

and you can set alpha programatically or through xml for setting transparency

now If Set Alpha You said deprecated and don't want to take risk by using this then just set color of image view

i just explain how to handle 1st imageview's click

 @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            if(v==imageview1){
                        //set lighter dark layer on click of image 1 and reset fully transparent layer on other image  
                imageview1.setBackgroundColor(Color.parseColor("#11000000"));
                imageview2.setBackgroundColor(Color.parseColor("#00000000"));
                imageview3.setBackgroundColor(Color.parseColor("#00000000"));
                imageview4.setBackgroundColor(Color.parseColor("#00000000"));

            }

        } 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top