试试这个,你可以使用自定义工具栏,为此目的在layout.xml:
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="parallax"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@mipmap/ic_launcher"
android:id="@+id/toolbar_title" />
现在设置工具栏的标题和标志像这样在onCreate()方法的activity.java文件中:
不要忘了在style.xml添加此主题的活动:
或者你可以试试这个,如果你不希望使用自定义工具栏:
ActionBar actionBar = getSupportActionBar()
actionBar.setIcon(R.mipmap.ic_launcher_round); // showing the icon to your action bar
actionBar.setTitle("");//set title to your action bar