Android - 来自中心的ScaleAnimation不能按预期用于某些视图

时间:2016-04-22 20:21:42

标签: android android-layout android-animation

我有一个活动,在onCreate上运行这段代码:

    AnimationSet animation = new AnimationSet(true);
    animation.addAnimation(new AlphaAnimation(0f, 1f));
    animation.addAnimation(new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animation.setDuration(4000); // should be 300
    animation.setFillAfter(true);

    View i1 = findViewById(R.id.load_mainimg);
    View i2 = findViewById(R.id.load_text1);
    View i3 = findViewById(R.id.load_text2);
    View i4 = findViewById(R.id.load_imgbtn_about);
    View i5 = findViewById(R.id.load_imgbtn_settings);
    View i6 = findViewById(R.id.load_btn1);
    View i7 = findViewById(R.id.load_btn2);
    i1.startAnimation(animation);
...
    i7.startAnimation(animation);

但是,TextViews(i2,i3)和ImageButtons(i4,i5)不会从中心缩放。 (i1是ImageView,i6和i7是LinearLayouts。)我做错了什么?

0 个答案:

没有答案