如何在工具栏中居中放置ImageView?

尖刺连il

一直试图将徽标放在我的工具栏中。当我导航到下一个活动时,将显示“增加能力”图标,它会将我的徽标稍微向右推。如何将徽标保留在工具栏的中央,而又不删除上限额图标?

这是我的工具栏标签

<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>
TD阮

javadoc中,它说:

一个或多个自定义视图。该应用程序可以向工具栏添加任意子视图。它们将出现在布局中的此位置。如果子视图的Toolbar.LayoutParams的Gravity值设置为CENTER_HORIZONTAL,则在测量完所有其他元素之后,该视图将尝试在工具栏剩余的可用空间内居中

这意味着除非创建自定义toolbar或删除,否则您将无法执行此操作icon

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章