0

私は現在、this imageのような引き出しレイアウトとTabLayoutでアクティビティを作成しています。しかし、私は実際にタブのタイトルを表示することに問題があります。これはhereで見ることができます。表示できるタブを変更するために左右にスワイプすることはできますが、タブバーのタイトルは表示されません。XamarinのAndroidで同時に引き出しレイアウトとタブレイアウトを使用する

ここでの活動のための.xmlレイアウトは(あなたの情報のために、私はこのレイアウトのための活動ファイルにAppCompatActivityを使用しています)です:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:background="@android:color/white"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:minHeight="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" /> 

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/drawerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


<!-- The Main Content View --> 
<android.support.design.widget.TabLayout 
    android:id="@+id/request_tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:tabMode="fixed" 
    app:tabGravity="fill" 
    android:background="@color/colorPrimary" /> 
<android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="0px" 
     android:layout_weight="1" 
     android:background="@android:color/white" /> 

<!-- The Left Navigation Drawer --> 
    <ListView 
     android:id="@+id/leftDrawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="#818181" 
     android:dividerHeight="2dp" 
     android:background="#E3F2FD" /> 

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

</LinearLayout> 

私はXMLで少し周り手を加え、それが登場タブのタイトルが表示されない理由は、TabLayoutをDrawerLayoutの内側に配置しているためです。ただし、DrawLayoutをTabLayoutの外側に置くと、各タブ付きページのコンテンツは表示されません。

DrawerLayoutとTabLayoutの両方を使用してタブタイトルバーを表示する方法はありますか?

答えて

0

TabLayoutDrawerLayoutに入れても問題ありません。チェックはthe answers in this threadです。

コードで見つかった唯一の問題は、DrawerLayoutがレイアウトのルートビューではないことです。このコントロールを使用する場合は、ルートビューとして設計する必要があります。

関連する問題