在android中,我们可以将动画应用于特定的子对象而不是整个根对象吗
下面是我的代码示例: 我对视图进行了充气,只想向充气视图添加动画。现在它正在为整个布局做准备在android中,我们可以将动画应用于特定的子对象而不是整个根对象吗,android,animation,inflate,Android,Animation,Inflate,下面是我的代码示例: 我对视图进行了充气,只想向充气视图添加动画。现在它正在为整个布局做准备 LinearLayout lLay = (LinearLayout)this.findViewById(R.id.FirstContact); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDura
LinearLayout lLay = (LinearLayout)this.findViewById(R.id.FirstContact);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(500);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
lLay.addView(inflater.inflate(R.layout.genericrelativelayout, null, false), position);
lLay.setLayoutAnimation(controller);
当然,您只想在膨胀的视图上调用
View.setAnimation()
,而不必为layoutaimationcontroller
?我尝试过这样做,但RelativeLayout rlay=(RelativeLayout)this.findViewById(R.layout.genericrelativelayout)失败;rlay.setAnimation(set);你能再给我解释一下吗?谢谢“失败”是什么意思?它崩溃了?什么都没发生?如果是后者,请尝试rlay.startAnimation()或anim.start();谢谢但setStartOffSet()不起作用。我有一个循环来根据计数膨胀视图。如果我的计数是3,那么3个视图被夸大了。我希望每个孩子之间的动画延迟…这样他们在短时间延迟后被列在彼此下面。。。