2017-02-03 4 views

答えて

0

アクションバーのツールバーを使用するだけです。 ツールバーは、任意のカスタムビューを追加できるViewGroupです。

例:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:orientation="vertical"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:minHeight="?attr/actionBarSize" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:titleTextColor="@android:color/white" 
    android:background="?attr/colorPrimary"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <YourViewHere/> 

    </LinearLayout> 

</android.support.v7.widget.Toolbar> 

とあなたの活動中:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_my); 

    // Find the toolbar view inside the activity layout 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    // Sets the Toolbar to act as the ActionBar for this Activity window. 
    // Make sure the toolbar exists in the activity and is not null 
    setSupportActionBar(toolbar); 
} 
関連する問題