2016-03-03 46 views
0

我有ViewPager女巫已經在TabLayout突出線在底部:如何在Android ViewPager中更改當前標籤突出顯示位置?

enter image description here

我想找到方法,把高亮顯示的行上TabLayout的頂部,在例如:

enter image description here

我谷歌搜索,仍然googling回答,但沒有找到有用的信息。

我的活動:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:local="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar" /> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <android.support.v4.view.ViewPager 
       android:id="@+id/view_pager" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"/> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tab_layout" 
       android:layout_width="match_parent" 
       android:layout_height="?android:attr/actionBarSize" 
       android:background="@color/colorPrimary" 
       app:tabGravity="fill" 
       app:tabMode="fixed" 
       local:theme="@style/ViewPagerTheme" 
       style="@style/MyCustomTabLayout" 
       /> 

     </LinearLayout> 

    </FrameLayout> 

</LinearLayout> 

<fragment 
    android:id="@+id/fragment_navigation_drawer" 
    android:name="com.example.pc.teltonikaapplication.fragment.DrawerFragment" 
    android:layout_width="@dimen/nav_drawer_width" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:layout="@layout/fragment_navigation_drawer" 
    tools:layout="@layout/fragment_navigation_drawer" /> 

如果需要的解決方案更多的代碼,請讓我知道。

回答

0

您可以使用RelativeLayout。只需使突出顯示的行與TabLayout對齊即可。只需在RelativeLayout中使用layout_align_top即可。

+0

你能舉個例子嗎? – JonasSeputis

相關問題