How do I set an Android View's transparency with animation?

萝らか妹 提交于 2019-12-21 09:25:37

问题


I need to set the initial transparency for a TextView, but I don't know how to do it. On iPhone/iOS, it can be done easily with the alpha property. On Android, I've tried to set the alpha using AlphaAnimation but it's no good -- it doesn't work. It just returns to 100% alpha when the animation ends.

AlphaAnimation anim = new AlphaAnimation(1, 0.2f);
anim.setDuration(5000);
textView.startAnimation(anim);

Any ideas guys?


回答1:


You can set the alpha channel directly in a color value that you assign to the TextView. See Available Resource Types.



来源:https://stackoverflow.com/questions/2180677/how-do-i-set-an-android-views-transparency-with-animation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!