2016-09-07 7 views
-1

私はフラグメント内にタブレイアウトとビューページャーを持っています。私は私のtablayoutに2つのタブがあります。私のapp_bar_main.xmlにツールバーがあります。私のアプリを実行すると、tablayoutはツールバーを隠します。どのようにツールバーの後に配置することができますか? ここに私のコード がある、これは私のapp_bar_main.xmlファイルツールバーの後にタブレイアウトを配置する方法は?

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="#CC0000" 
     android:titleTextColor="@color/white" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<FrameLayout 
    android:id="@+id/fragment_containerlayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFFFFF"></FrameLayout> 

これは私がタブレイアウトとビューのページャを配置している私のフラグメントデザインである

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.nayab.demotask.ContactsFragment" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 


<android.support.design.widget.TabLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/contactstablayot" 
    android:layout_gravity="left|top" 
    android:background="#000000" 
    app:tabTextColor="@android:color/white" 
    /> 

<android.support.v4.view.ViewPager 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/fragviewpager" 
    android:layout_gravity="left|center_vertical" 
    android:layout_marginTop="30dp" 
    android:background="#e6f1f5" 
    /> 

can somebodyお手数ですが

+0

縦向きでのLinearLayout使用することができますか?上部にツールバーがあり、その下にタブレイアウトがあるただ1つの画面? – HourGlass

答えて

0

Framelayoutでapp:layout_behavior="@string/appbar_scrolling_view_behavior"を試してみてください。

+0

ありがとうalot ...それは働いた:) –

+0

okayyy ......... :) –

0

あなたがここに達成するために何をしようとしている

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="#CC0000" 
      android:titleTextColor="@color/white" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <FrameLayout 
     android:id="@+id/fragment_containerlayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#FFFFFF"></FrameLayout> 

</LinearLayout> 
関連する問題