2017-07-11 3 views
0

Wie plaziere ich Tablayout unter der Symbolleiste? Es gibt mir eine Fehlermeldung und wenn ich es ausführe, wird die Symbolleiste nicht angezeigt. Aber wenn ich die Tablayout geben alignbottom die Symbolleiste dann zeigtWie lege ich Tablayout unter meine Titelleiste?

Hier ist meine XML-Datei

<RelativeLayout 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" 
    android:id="@+id/rel" 
    tools:context="com.example.test.MainActivity"> 



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


    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/nvd_act_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/app_bar" 
     > 

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

      <TextView 
       android:id="@+id/lbl_act_main" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="Hello World!" /> 
     </FrameLayout> 


     <android.support.v7.widget.RecyclerView xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/lst_nav_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start|left" 
      android:background="@android:color/white" 
      app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> 
    </android.support.v4.widget.DrawerLayout> 


    <RelativeLayout 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_alignParentBottom="true" 
     android:background="#2480c1" 
     android:gravity="center" 
     android:layout_gravity="center"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tbl_basic" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent"> 
     </android.support.design.widget.TabLayout> 

     <TextView 
      android:id="@+id/lbl_basic_content" 
      android:layout_below="@id/tbl_basic" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="top" 
      android:textColor="@android:color/black" /> 
     </RelativeLayout> 

</RelativeLayout> 

Hier ist der Bildschirm i erstellt, die tablayout ist im Boden. Ich möchte, dass es direkt unter der Symbolleiste ist. Wie mache ich es?

Dank

Here

Hier ist die Fehlermeldung

@ id/rel keine Geschwister in der gleichen RelativeLayout Layoutbeschränkungen in einem bestimmten RelativeLayout ist, sollte andere Ansichten innerhalb der gleichen relativen Layout verweisen (aber nicht ! selbst)

+0

‚Es gibt mir eine Fehlermeldung‘ - Es wäre hilfreich für Leute, die Ihre Frage überprüfen, damit Sie die Fehlermeldung posten können. – dominicoder

Antwort

0

versuchen diese Änderung android: layout_alignParentBottom = "wahr" zu und roid: layout_alignParentBottom = „falsch

<RelativeLayout 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_alignParentBottom="false" 
     android:layout_below="@+id/app_bar " 
     android:background="#2480c1" 
     android:gravity="center" 
     android:layout_gravity="center"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tbl_basic" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent"> 
     </android.support.design.widget.TabLayout> 

     <TextView 
      android:id="@+id/lbl_basic_content" 
      android:layout_below="@id/tbl_basic" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="top" 
      android:textColor="@android:color/black" /> 
     </RelativeLayout> 
+0

hat nicht funktioniert, Herr. Die Werkzeugleiste verschwindet – kurokocrunch

+0

bearbeitet check oyt – seon

+0

gearbeitet. Vielen Dank! – kurokocrunch

0

Wenn Sie es unter der Symbolleiste wollen, dann legen Sie sie unter der Symbolleiste:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rel" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

    <RelativeLayout 
     android:layout_below="@id/app_bar" 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_gravity="center" 
     android:background="#2480c1" 
     android:gravity="center"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tbl_basic" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
     </android.support.design.widget.TabLayout> 

     <TextView 
      android:id="@+id/lbl_basic_content" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@id/tbl_basic" 
      android:gravity="top" 
      android:textColor="@android:color/black" /> 
    </RelativeLayout> 

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/nvd_act_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/app_bar" 
     > 

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

      <TextView 
       android:id="@+id/lbl_act_main" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="Hello World!" /> 
     </FrameLayout> 

     <android.support.v7.widget.RecyclerView xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/lst_nav_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start|left" 
      android:background="@android:color/white" 
      app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> 
    </android.support.v4.widget.DrawerLayout> 

</RelativeLayout> 
Verwandte Themen