TabLayout not showing tabs after adding navigation bar

前端 未结 1 1649
闹比i
闹比i 2021-01-24 21:55

i am working with ViewPager + TabLayout. It was working fine, but after i added navigation bar, the TabLayout is not showing tabs. I searched for solution but none of them helpe

相关标签:
1条回答
  • 2021-01-24 22:12

    Please refer this code. Add the tab layout inside a appbar layout.Try this

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="200dp"
        android:id="@+id/appBarLayout2">
    
    
        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tabLayout2"
            app:tabMode="fixed"
            app:tabGravity="fill"
    
            ></android.support.design.widget.TabLayout>
    
    </android.support.design.widget.AppBarLayout>
    
    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/viewPager2"
        android:layout_below="@+id/appBarLayout2">
    
    </android.support.v4.view.ViewPager>
    
    0 讨论(0)
提交回复
热议问题