2015-06-27 63 views
1

我試圖瞭解如何使用材質設計在我的應用程序的自定義「工具欄」上設置滑動選項卡。據我瞭解,我需要一個'ViewPage',這是否意味着我需要創建一個'ViewPager',並設置其'適配器'?我想我會用相關數據填充我的片段視圖。有人可以幫助解釋如何去做這件事嗎?如何設置一個ViewPage和它的適配器在android中?

我只打算使用兩個選項卡。

到目前爲止,我有我的XML這是我從https://www.youtube.com/watch?v=tRg_eDfQ8fk了,它看起來像這樣:

<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"/> 

任何幫助表示讚賞。

+0

該視頻嚴重過時。標籤佈局現在是新設計支持庫的一部分,您應該查看它們。請參閱[Google的博客](http://android-developers.blogspot.hu/2015/05/android-design-support-library.html)瞭解kickstart。 – vzsg

+0

感謝您的信息@vzsg! –

回答

相關問題