2017-01-02 387 views
3

我尝试开发像这样的图像左TabLayout。垂直Android TabLayout不垂直滚动

enter image description here

但问题是TabLayout元素不是表演和垂直滚动。下面有我的代码也许我错过了一些东西:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toRightOf="@+id/appBarLay" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBarLay" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="60dp" 
      android:layout_height="match_parent" 
      app:tabBackground="@drawable/tab_color_selector" 
      app:tabGravity="fill" 
      app:tabMode="scrollable" /> 
    </android.support.design.widget.AppBarLayout> 
</RelativeLayout> 
+1

Tablayout并不意味着垂直滚动,他们只进行水平滚动。 我认为你应该看看别的。 –

+0

@PriyaSinghal,请告诉我什么是正确的方式。我在GitHub中找到了一些库,但有没有其他方法? –

+2

使用可以使用ListView或RecyclerView与固定宽度,因为我认为你需要用选择的选项类型来填充屏幕...... 另外你试图制作的UI是在IOS的指导下进行的if可能会要求您的设计师将设计作为android的android指南。 –

回答

3

由于Android文档中提到,看到this

TabLayout提供了一个水平布局显示选项卡。

这意味着您不能使用TabLayout来显示垂直制表符。但是,您可以使用TabHost来实现它。

查阅这些链接才可:

http://www.androidhive.info/2011/08/android-tab-layout-tutorial/

Vertical tabs in Android

+0

谢谢你,但是在你给出的例子中找不到Left Tab。 –

+0

在stackoverflow的答案中有一个垂直制表符的例子。看到这个http://stackoverflow.com/a/7268225/5722608 –

+0

我已经试过这个类型的例子,主要问题是这个标签不是动态的,并且看起来不像TabLayout。 –