2016-09-07 1 views
-1

Ich habe ein Tablayout und einen Viewpager in einem Fragment. Ich habe zwei Tabs in meinem Tablayout. und eine Symbolleiste in meiner app_bar_main.xml. aber wenn ich mein app tablayout starte, blendet die toolbar aus. Wie kann es nach der Symbolleiste platziert werden? hier ist mein Code das ist mein app_bar_main.xml DateiWie wird das Tab-Layout nach der Symbolleiste platziert?

<?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> 

das ist mein Fragment Design, wo ich eine Registerkarte Layout und einen Blick Pager

<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" 
    /> 
gesetzt haben

kann jemand Bitte helfen Sie mir

+0

verwenden können Linearlayout, was Sie hier zu erreichen versuchen? nur ein einziger Bildschirm mit Symbolleiste oben und tablayout darunter? – HourGlass

Antwort

0

Versuchen Sie app:layout_behavior="@string/appbar_scrolling_view_behavior" auf Ihrem Framelayout zu verwenden.

+0

danke viel ... es hat funktioniert :) –

+0

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

0

Sie mit Ausrichtung vertikal

<?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> 
Verwandte Themen