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
!!
使用startAnimation()
而不是setAnimation()
并在setVisibility()
之后调用它
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 !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.