开发者

Can we apply animation to a specific child and not the entire root in android

Below is my code example: I inflated a view and want to add animation to only the inflated one. Right now its doing for the entire layout.

    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.addA开发者_StackOverflow社区nimation(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);


Surely you just want to call View.setAnimation() on your inflated view, and not bother with LayoutAnimationController?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜