2

I am trying to change the view Alpha using setAlpha(int a) method, but it has no effect and also tried to perform alpha animation on same but the same result!. Please help. Here is the part of code..

public void run() {
            runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        myImage.setAlpha(1);
                    }
                });

        }
CodeFury
  • 1,520
  • 16
  • 29
  • 3
    That method is deprecated. You should use setImageAlpha(int alpha) instead, though I don't know whether that solves the problem. – DuneCat Oct 05 '12 at 08:24
  • 1
    @DuneCat How did you come to the conclusion that it is deprecated? I see no mention of it at http://developer.android.com/reference/android/view/View.html#setAlpha(float) – faizal Jul 08 '14 at 05:04
  • 2
    @faizal It's not deprecated in View, but in ImageView: http://developer.android.com/reference/android/widget/ImageView.html#setAlpha%28int%29 – DuneCat Jul 09 '14 at 13:31

2 Answers2

9

I don't know which values you've tried using, but the method takes values from 0 to 255, where 255 is completely opaque, as per this answer.

Community
  • 1
  • 1
DuneCat
  • 788
  • 6
  • 17
2

Try this:

myImage.getBackground().setAlpha(100);
GitaarLAB
  • 14,536
  • 11
  • 60
  • 80