1

Im trying to learn about how to set up sliding tabs on my app's custom 'Toolbar' using material design. As I understand it, I'll need a 'ViewPage', does that mean i need to create a 'ViewPager', and set its 'Adapter'? Which I suppose will populate my fragment views with the relevant data. Can someone help explain how to go about doing this?

I'm only planning to use two tabs.

So far i have my xml which I got from https://www.youtube.com/watch?v=tRg_eDfQ8fk , it looks like this:

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

Any help is appreciated.

Lighterletter
  • 209
  • 2
  • 13
  • That video is seriously outdated. Tab layouts are now a part of the new Design Support library, you should look into them. See [Google's blog](http://android-developers.blogspot.hu/2015/05/android-design-support-library.html) for a kickstart. – vzsg Jun 27 '15 at 18:07
  • Thanks for the info @vzsg! – Lighterletter Jun 27 '15 at 21:16

1 Answers1

0

So I was able to figure it out. I'm posting the article that helped me in case anyone also needs to solve the problem.

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

The Article talks about setting up the tabs after setting up the toolbar (Which they also link to) and how to set up your fragments as well. Really useful.

Lighterletter
  • 209
  • 2
  • 13