代码之家  ›  专栏  ›  技术社区  ›  Matej KoÅ¡út

Android:如何在浏览视图中创建静态元素?

  •  0
  • Matej KoÅ¡út  · 技术社区  · 9 年前

    我正在开发一个应用程序,我想在一开始就演示如何使用它。我正在使用带有碎片的ViewPager。这一切都很好,但我如何才能使一些元素(如按钮或徽标)保持静态?我希望它们是永久的,只有背景和一些其他元素可以在滑动时移动或更改。

    1 回复  |  直到 9 年前
        1
  •  0
  •   TheoKanning    9 年前

    如果你希望它们是静态的,那么它们就不能成为 Fragments ViewPager 。你可以把它们放在 查看寻呼机 用一个 RelativeLayout ,或者您可以使用 FrameLayout .

    下面的静态内容示例 查看寻呼机

    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>