2016-05-25 11 views
0

Ich bin gerade dabei, zu lernen, wie man eine Symbolleiste erstellt. Ich habe viele Bereiche durchsucht, konnte aber nicht finden, wie man die Symbolleiste ändert, so dass ich 2 Zeilen habe. 1. Zeile für Navigation und Titel. 2. Reihe für SuchleisteÄndern der Symbolleiste zum Hinzufügen einer neuen Zeile

Beispiel:

enter image description here

+1

Die Suchleiste nicht im 'Toolbar' zu leben hat, kann es ein separates Element sein unmittelbar darunter. Vielleicht könntest du sie beide in einem 'AppBarLayout' haben. – Karakuri

Antwort

0

ich es tat. Ich entfernte die SearchView aus dem Menü und legte sie in das Hauptlayout. Mein Layout XML wie folgt aussieht:

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

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorToolBar" 
     android:paddingBottom="16dp" 
     android:elevation="4dp"> 

     <android.support.v7.widget.SearchView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="16dp" 
      android:layout_marginLeft="16dp" 
      android:id="@+id/main_home_search" 
      android:background="@color/searchBackgroundColor" 
      android:focusable="false" 
      app:queryHint="@string/main_home_search" 
      app:queryBackground="@android:color/transparent" 
      app:iconifiedByDefault="false" 
      /> 

    </LinearLayout> 

    <include layout="@layout/activity_main_home_content" /> 

</LinearLayout>