一直试图将徽标放在我的工具栏中居中。当我导航到下一个活动时,会出现“向上可供性”图标,它将我的徽标稍微向右推。如何将我的徽标保留在工具栏的中心,而不删除向上的可供性图标?
这是我的工具栏标签
<android.support.v7.widget.Toolbar
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="wrap_content"
android:background="@color/primaryColor"
android:paddingTop="@dimen/app_bar_top_padding"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:theme="@style/CustomToolBarTheme">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_android_logo"
android:layout_gravity="center"
android:paddingBottom="3dp"/>
</android.support.v7.widget.Toolbar>
您可以按照以下方式进行操作,这对我有用:
<androidx.appcompat.widget.Toolbar
android:id="@+id/mainToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="@dimen/abc_action_bar_default_height_material">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/headerLogo"
android:contentDescription="@string/app_name" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)