Reputation: 6073
I'm working on application, and I have an Activity
where I have to show a TextView
.
Initially the TextView
is invisible, but when I have to make it visible I set an animation before. The animation works fine on Alcatel One Touch API 17, HTC One X API 17 and Samsung S3 Neo API 19 but on the Nexus 5 API 23 it still uses the default animation while being visible (fade in).
Is there any reason for that to happen? This is the code I use:
myTextView.setAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.come_in_from_left));
myTextView.setVisibility(View.VISIBLE);
Edit
I just noticed that when im not on debugger the animation don't work at all on all the devices !!! it look like i need to keep my devices connected to ADB
!!
Upvotes: 1
Views: 493
Reputation: 6073
I finally resolve it , there was two issues :
First
My TextView
was inside a RelativeLayout
which has a LinearLayout
as parent, the attribute andoid:animateLayoutChanges
was first mentioned in the RelativeLayout
,i moved it inside LinearLayout
.
Second
As mreza sh suggested to me , i replace setAnimation()
with startAnimation()
and call it after setVisibility()
Now it works fine on all devices , even disconnected from the debugger !
Upvotes: 1
Reputation: 545
use startAnimation()
instead of setAnimation()
and call it after setVisibility()
Upvotes: 2