2016-05-25 12 views
0

現在、ツールバーの作成方法を学習中です。私は多くの分野を検索しましたが、ツールバーを修正する方法を見つけることができませんでしたので、私は2行を持っています。 ナビゲーションとタイトルの第1行。検索バーのための 2行目新しい行を追加するためのツールバーの変更

例:私はそれをやった

enter image description here

+1

、それはそれ以下の別々の要素とすることができます。おそらく、あなたはそれらを両方とも 'AppBarLayout'の内部に置くことができます。 – Karakuri

答えて

0

。私は、メニューからSearchViewを削除し、メインレイアウトに配置しました。私のレイアウトXMLは次のようになります。検索バーが `Toolbar`内で生活する必要はありません

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