Android:如何在滑动视图中制作静态元素?

时间:2016-02-18 15:16:30

标签: android android-viewpager views swipe

我正在开发一个应用程序,在那里我想介绍如何在beginnig中使用它。我正在使用ViewPager和fragemts。一切正常,但我怎样才能制作一些元素,例如按钮或徽标静态?我希望它们是永久性的,只有背景和其他一些元素可以在滑动时移动或更改。

1 个答案:

答案 0 :(得分:0)

如果您希望它们是静态的,那么它们就不能成为FragmentsViewPager的一部分。您可以使用ViewPager将它们放在RelativeLayout的上方或下方,也可以使用FrameLayout将它们置于顶部。

ViewPager

下的静态内容示例

<强> fragment_pager.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_width="match_parent" >

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:id="@+id/static_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/container" />

</RelativeLayout>