Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
Created January 5, 2016 08:00
Show Gist options
  • Save yuanliwei/d33db961cc364e13d1bb to your computer and use it in GitHub Desktop.
Save yuanliwei/d33db961cc364e13d1bb to your computer and use it in GitHub Desktop.
ViewAnimator 使用

ViewAnimator 使用

布局

<ViewAnimator
    android:id="@+id/sample_output"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:inAnimation="@android:anim/fade_in"
    android:outAnimation="@android:anim/fade_out">

    <TextView
        style="@style/Widget.SampleMessage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/intro_message"/>

    <fragment
        android:id="@+id/log_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</ViewAnimator>

java调用

ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
if (mLogShown) {
    output.setDisplayedChild(1);
} else {
    output.setDisplayedChild(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment