如何更改imageview的alpha值

ram*_*ams 2 android alpha image

在我的应用程序中,我想更改ImageView,如下所示.我只想改变身体上的图像.

在此输入图像描述

我已按照以下链接使用类似的代码更改alpha值

imageView.setAlpha(255);
Run Code Online (Sandbox Code Playgroud)

但它没有用.

如何在Android中为View设置不透明度(Alpha).请有人建议我怎么做.

Mar*_*vic 17

也许你可以尝试这样,我有麻烦做正常的方式,但有"动画",这是好的.

AlphaAnimation alpha = new AlphaAnimation(0.5F, 0.5F); // change values as you want
alpha.setDuration(0); // Make animation instant
alpha.setFillAfter(true); // Tell it to persist after the animation ends
// And then on your imageview
yourImageView.startAnimation(alpha);
Run Code Online (Sandbox Code Playgroud)