2016-05-12 134 views

回答

1

工具栏是一个ViewGroup中,所以你可以添加一个孩子的ImageView它:

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay"> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:src="@drawable/image"/> 
    </android.support.v7.widget.Toolbar> 

</android.support.design.widget.AppBarLayout> 
1

您可以使用工具栏的应用程序动作条(通过setActionBar或setSupportActionBar)。

工具栏是一个ViewGroup,因此您可以根据需要更改其布局(将imageview添加到图像中)