views:

41

answers:

1

This is a strange problem -- may be not a problem.

Before the last step to finish writing a application, I would use icon to replace any image. That is, all the things like

<ImageButton
    android:id="@+id/top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="center"
    android:src="@drawable/icon" />

The problem appears then. I set the imageButton alpha to 50, then all the images' alpha low to 50, Even in different activities. I start an activity as main entry, then start another activity from main entry. I set imageButton source as icon in xml file. Then I set its alpha value to 50(any value you like), then when I finish the activity, back to the main entry, all the "icons" set its alpha value to 50. Then I start another activity and found all the "icons" there are 50 alpha.

I just wonder why? Can any one answer me? My development phone is HTC magic 1.5, official rom. Thanks!

Code 1:

Runnable doHide = new Runnable() {
    @Override
    public void run() {

        if (intHidingButtonPanelAlpha <= 0) {
            imageButtonTop.setVisibility(ImageButton.GONE);
            imageButtonNext.setVisibility(ImageButton.GONE);
            imageButtonPrevious.setVisibility(ImageButton.GONE);

            imageButtonTop.setAlpha(255);
            imageButtonNext.setAlpha(255);
            imageButtonPrevious.setAlpha(255);

            return;
        }

        imageButtonTop.setAlpha(intHidingButtonPanelAlpha);
        imageButtonNext.setAlpha(intHidingButtonPanelAlpha);
        imageButtonPrevious.setAlpha(intHidingButtonPanelAlpha);
        intHidingButtonPanelAlpha -= 85;
    }
};

Code 2:

for (int i = 0; i < 4; i++) {
        handlerHider.postDelayed(doHide, 600 * i);
    }

Hope this can help you to understand what I did. At present, all imageButtons' source are drawable.icon.

A: 

My guess is that you are running into the problem described in this article. You will need to use the mutate() method as described therein.

CommonsWare