1

我试图了解如何使用材料设计在我的应用程序的自定义“工具栏”上设置滑动选项卡。据我了解,我需要一个“ViewPage”,这是否意味着我需要创建一个“ViewPager”并设置它的“Adapter”?我想这会用相关数据填充我的片段视图。有人可以帮助解释如何去做吗?

我只打算使用两个选项卡。

到目前为止,我有我从https://www.youtube.com/watch?v=tRg_eDfQ8fk获得的 xml ,它看起来像这样:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activity_main"
tools:context=".MainActivity">

<include layout="@layout/tool_bar"/>

<com.example.android.common.view.slidingTabLayout
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />
<android.support.v4.view.ViewPager
    android:id="@+id/viewpages"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:background="@android:color/holo_blue_light"/>

任何帮助表示赞赏。

4

1 回答 1

0

所以我能够弄清楚。我正在发布对我有帮助的文章,以防任何人也需要解决问题。

http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

这篇文章讨论了在设置工具栏(它们也链接到)之后设置选项卡以及如何设置您的片段。真的很有用。

于 2015-06-27T21:13:51.310 回答