2017-02-03 2 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); 
} 
Смежные вопросы