By Alvin Alexander. Last updated: June 6, 2016
The Google/Android SlidingTabsColor project has a little example of how to use a ViewAnimator
widget. Here’s the XML layout portion of the ViewAnimator
:
<ViewAnimator android:id="@+id/sample_output" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1"> <ScrollView style="@style/Widget.SampleMessageTile" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView style="@style/Widget.SampleMessage" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/horizontal_page_margin" android:paddingRight="@dimen/horizontal_page_margin" android:paddingTop="@dimen/vertical_page_margin" android:paddingBottom="@dimen/vertical_page_margin" android:text="@string/intro_message" /> </ScrollView> <fragment android:name="com.example.android.common.logger.LogFragment" android:id="@+id/log_fragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </ViewAnimator>
See that project for more information on how it works. I just started to integrate a tabs layout into an Android 5 project, and this is what the ViewAnimator looks like:
This is the view I see when my current Android app starts up.