Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invisible / transparent button that works like a regular in android?

How do I get one area in the middle of a image clickable (not the whole image)? Tried with a button set to invisible and clickable but the button does not work. What are the alternatives to an invisible / transparent button that works like a regular?

I've also thought of a completely transparent and clickable PNG that should work but maybe not the best way?

like image 620
Xtreme Avatar asked Sep 23 '10 05:09

Xtreme


People also ask

How do you make a button background transparent?

CSS Code: In this section, we will design the button using CSS property. We will use the background-color: transparent; property to set the button with transparent look. Complete Code: In this section, we will combine the above two sections to create a transparent background button.

What is Android visibility?

A View's visibility status is of Integer type and can have one of three options: VISIBLE (0) - The View is visible to the user. INVISIBLE (4) - The View is invisible to the user, but still takes up space in the layout. GONE (8) - The View is invisible, and it does not take up space in the layout.


1 Answers

Here you go:

Button theButton = (Button)findViewById(R.id.theButton); theButton.setVisibility(View.VISIBLE); theButton.setBackgroundColor(Color.TRANSPARENT);  phoneButton.setOnClickListener(new OnClickListener() {        @Override     public void onClick(View v)     {         // DO STUFF     } }); 
like image 63
ingh.am Avatar answered Sep 25 '22 17:09

ingh.am