1

Gridlayout(它在相对布局中居中)

<GridLayout
    android:id="@+id/ticketLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/pile"
    android:visibility="gone"
    android:animateLayoutChanges="true" >

<!-- some content -->

现在当我让它可见时

ticketLayout.setVisibility(View.VISIBLE);

它只是出现,根本没有动画。我错过了什么吗?

4

2 回答 2

1

你需要为你的View. 例如,您可以这样做:

mticketLayout.setAlpha(0f);
mticketLayout.setVisibility(View.VISIBLE);

// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
mticketLayout.animate()
        .alpha(1f)
        .setDuration(mShortAnimationDuration)
        .setListener(null);

看看 Android 培训:http: //developer.android.com/training/animation/crossfade.html

于 2013-11-13T15:50:48.877 回答
1

没有默认动画。为了实现您想要的,我认为您需要在 gridview 的 alpha 属性上播放动画。根据您想要支持的最低 API,您可以使用旧动画系统或新动画系统,甚至使用 NineOldAndroids。

animateLayoutChange 标志指定如果您在此网格视图内动态添加视图,系统将必须播放默认动画。(很可能是褪色效果)它对网格视图本身没有帮助。

于 2013-11-13T15:44:16.803 回答