2015-09-29 90 views
1

我在我的Android應用中添加了新的Toolbar,TablayoutViewpager。我想創建此我使用ViewPager刷卡應用。滑動和Tablayout滾動不起作用。在Android ViewPager中使用Fragment和TabLayout滾動滑動不工作

main.xml中

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


    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:minHeight="?attr/actionBarSize" 
     android:background="@color/toolbar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 


     <Spinner 
      android:id="@+id/customspinner" 
      android:layout_width="180dp" 
      android:layout_height="46dp" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" 
      android:background="@color/toolbar" 
      android:layout_gravity="right" 
      android:dropDownWidth="500dp" 
      android:dropDownVerticalOffset="100dp" 
      /> 


    </android.support.v7.widget.Toolbar> 


    <android.support.design.widget.TabLayout 
     app:tabMode="scrollable" 
     android:id="@+id/tab_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/toolbar" 
     android:background="@color/list_background" 
     android:elevation="10dp" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 


     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@id/tab_layout"/> 


    <android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 


     <FrameLayout 
      android:id="@+id/frame_container1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <ExpandableListView 
      android:id="@+id/list_slidermenu" 
      android:layout_width="360dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:background="@color/list_background" 
      android:choiceMode="singleChoice" 
      android:dividerHeight="1dp" 
      android:divider="@android:color/darker_gray" 
      android:groupIndicator="@null" > 
     </ExpandableListView> 


    </android.support.v4.widget.DrawerLayout> 

</RelativeLayout> 

DrawerLayout去躲當我改變的地方DrawerLayoutTabLayout

謝謝。

+0

你能更簡單的關於您的問題? – Sjd

+0

TabLayout當我更換tablayout至底部滾動。 –

+0

你有沒有得到這個問題的答案。我面臨着類似的問題。 – Saraschandraa

回答

0

你使用它?

// Setting the ViewPager For the SlidingTabsLayout 
    tabs.setViewPager(pager); 
0

你必須添加這個來改變頁面,反之亦然。

viewPager.addOnPageChangeListener(newTabLayout.TabLayoutOnPageChangeListener(tabLayout)); 
    tabLayout.setTabsFromPagerAdapter(mAdapter); 
相關問題