以Nav Drawer按钮为中心的Android工具栏图像

以Nav Drawer按钮为中心的Android工具栏图像,第1张

概述我有带有图像作为徽标的工具栏,徽标居中.但是当我放置导航抽屉时,徽标向右移动,因为有导航抽屉按钮.如何使徽标始终与工具栏中的导航抽屉按钮居中?谢谢.我的密码<android.support.design.widget.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="w

我有带有图像作为徽标的工具栏,徽标居中.但是当我放置导航抽屉时,徽标向右移动,因为有导航抽屉按钮.如何使徽标始终与工具栏中的导航抽屉按钮居中?

谢谢.

我的密码

<androID.support.design.Widget.AppbarLayout  androID:layout_wIDth="match_parent"  androID:layout_height="wrap_content"  androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar">    <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/themeOverlay.AppCompat.light">           <ImageVIEw              androID:layout_wIDth="match_parent"              androID:layout_height="25dp"              androID:src="@drawable/logo"/>     </androID.support.v7.Widget.Toolbar>     <androID.support.design.Widget.TabLayout         androID:ID="@+ID/tabs"         androID:layout_wIDth="match_parent"         androID:layout_height="wrap_content"         androID:background="?attr/colorPrimaryDark"         app:tabGravity="fill"         app:tabMode="fixed" /></androID.support.design.Widget.AppbarLayout>

解决方法:

尝试以下布局:将androID:layout_gravity =“ center_horizo​​ntal”添加到ImagevIEw

<androID.support.design.Widget.AppbarLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar">        <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/themeOverlay.AppCompat.light">            <ImageVIEw                androID:layout_wIDth="match_parent" //change this to wrap_content                androID:layout_height="25dp"                androID:layout_gravity="center_horizontal"                androID:src="@drawable/logo"/>        </androID.support.v7.Widget.Toolbar>        <androID.support.design.Widget.TabLayout            androID:ID="@+ID/tabs"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:background="?attr/colorPrimaryDark"            app:tabGravity="fill"            app:tabMode="fixed" />    </androID.support.design.Widget.AppbarLayout>
总结

以上是内存溢出为你收集整理的以Nav Drawer按钮为中心的Android工具栏图像全部内容,希望文章能够帮你解决以Nav Drawer按钮为中心的Android工具栏图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1120975.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存