0

A couple of weeks ago I think I read something about makeing a Button or any other View group a bit faded or less visible to show that it is not in use, but can be used if the user does something. Now I can not find it anywhere, and I really want to use it.

Does anyone know what it is and if it is useable in android 2.1?

Magakahn
  • 498
  • 9
  • 31

4 Answers4

1

//give 0 for full transparent 255 for completely opaque.

Mybutt.getBackground().setAlpha(100);
Padma Kumar
  • 19,893
  • 17
  • 73
  • 130
1

you can use below method , if Button is not enable and you want to show user that it is not in use.

mButton.setEnabled(false); // if it is not enable and you want to show user that it is not in use.

and

mButton.setEnabled(true); // to make it enabled/ in use
AAnkit
  • 27,299
  • 12
  • 60
  • 71
0

Did you try this:

mButton.getBackground().setAlpha(127); // semi transparent
AMerle
  • 4,354
  • 1
  • 28
  • 43
  • The button is still clickable – Magakahn Jul 18 '12 at 11:01
  • @Magakahn then implement your own CustomButton and Override the setEnabled(boolean) method to change its opacity =) – AMerle Jul 18 '12 at 11:03
  • I am pretty sure it was a state not a replacement – Magakahn Jul 18 '12 at 11:04
  • @Magakahn of course you can use a [StateList](http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList) too – AMerle Jul 18 '12 at 11:05
  • But it was a already defined state. I think I have found it now and it is called disabeled. http://developer.android.com/design/style/touch-feedback.html – Magakahn Jul 18 '12 at 11:06
  • @Magakahn this state is used when the button's state is disabled, so why don't you just call mButton.setEnabled(false) ? – AMerle Jul 18 '12 at 11:09
  • I found it out now. One of (in my case edittext) where focused and could still be selected after disabeling it. Thanks – Magakahn Jul 18 '12 at 11:13
0

You can use an AlphaAnimation on any view / viewgroup and its children.

Check out this answer.

Community
  • 1
  • 1
Benito Bertoli
  • 25,285
  • 12
  • 54
  • 61