4

I have been trying to achieve this semi-transparent button, but I always failed on making that. I have referred many like this. But still no luck. I tried with android:color="#66FF0000" too, but it doesn't make it semi-transparent. Below is my code.

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:text="select"
        android:onClick="selectClick"
        android:color="#80000000" 
      />

I want this type of rectangular button with semi transparent so that blue color of button should be visible and green color of the activity should also be visible. Can someone please suggest me? In the below picture I was unable to draw green color on the button to show what exactly I want. But I guess my above explanation is understandable.

Or if the blue color is not possible to be made visible, at least I want it to look like to give a user feel that there is a button and the green color should be visible.

enter image description here

Community
  • 1
  • 1
Apparatus
  • 411
  • 1
  • 5
  • 19
  • http://stackoverflow.com/questions/2838757/how-to-set-opacity-alpha-for-view-in-android possible duplicate – Chanchal Shelar Apr 01 '13 at 07:45
  • 1
    @ChanchalShelar It's easy to say duplicate than answering a question exactly. I already mentioned that link in my question which implies that you didn't read my question clearly. – Apparatus Apr 02 '13 at 03:31

1 Answers1

11

Use

android:background="#80000000"

instead of

android:color="#80000000"

M.J
  • 586
  • 6
  • 16
  • It displays the button in ash color, but the shape is fine. Can you please suggest me another one to look like it is transparent? – Apparatus Apr 02 '13 at 03:39
  • 2
    Of which color you want you button to be? To make any color transparent you just need to change the value of first two digits from "#00000000" if you want your button to be 50% transparent then use #50xxxxxx of any color then your button will be 50% transparent 00 represents full transparency you can chose any value between 00 to 99 to set the transparency level for your button. You can choose color from http://www.allprofitallfree.com/color-wheel2.html – M.J Apr 02 '13 at 04:02
  • 2
    Erm, I don't think that's right. The values for each channel are represented by two characters from 00 to FF where FF = 255 in decimal. 50% would not therefore equate to 50 in hex. The easiest way to get the correct value would be 255 * 50% (or 0.5) = 127.5 which you then round down to 127 which is 7F in Hex – Wayne Phipps Sep 20 '13 at 08:01