AlphaAnimation does not work

前端 未结 3 411
南旧
南旧 2020-12-09 01:42

I have been looking for a solution to my problem. But my code seems to be ok.

I\'ll try to explain: I have a TextView with android:alpha=\"0\" in my layout definiti

3条回答
  •  萌比男神i
    2020-12-09 01:59

    The problem is in android:alpha="0". This property sets transparency of a View http://developer.android.com/reference/android/view/View.html#attr_android:alpha

    When alpha property is equal to 0 then animation is changing transparency from 0*0.0f=0 to 0*1.0f=0. When alpha property is set to 1 then animation is changing transparency from 1*0.0f=0 to 1*1.0f=1. That's why in first case you can't see text and in the second everything works as expected.

    To make things work you have to set visibility property to invisible in layout xml. And before starting alpha animation call tv.setVisibility(View.VISIBLE);

提交回复
热议问题