![](/img/trans.png)
[英]How do I have an ActionBar icon/logo that overlaps the content as well?
[英]How do I center a logo in the ActionBar?
由於您無法訪問視圖,因此您無法將其居中,除非有一個我認為沒有的功能,這就是為什么我總是讓我自己的工具欄使用這個:
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/navigation_background"
android:layout_gravity="center"/>
</androidx.appcompat.widget.Toolbar>
現在在您的代碼中使用:
...
setSupportActionBar(toolbar);
通過將樣式更改為:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.