开发者

Are images in Android global?

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜