android - 工具栏内的文本未居中
问题描述
我在XML
. 但RelativeLayout
不完全适合Toolbar
,距离左侧约 10dp。
的代码XML
:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@color/colorAccent">
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/supporter"
android:layout_alignParentRight="true"
/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/title_toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/yekan"
android:text="@string/appnameForUsers"
android:textColor="@android:color/white"
android:textSize="24sp"
android:layout_centerHorizontal="true"
/>
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/supporter"
android:layout_alignParentLeft="true"
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
解决方案
app:contentInsetStart="0dp"
在您的工具栏中添加此属性
推荐阅读
- css - CSS 中的“@media screen”是什么?
- java - QueryDsl 没有生成正确的类型
- android - 如何在 ViewModel 类 Kotlin 的函数中使用存储库对象?
- c# - 如果字符串数组中的列名在字符串数组中具有匹配值,则获取 DataRow
- java - 在 openapi 文件中添加 helidon 对象健康和指标
- javascript - Node/Postgresql Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
- python - 用于计算市场流域的 MCP Geometrics
- javascript - AJAX 和 PHP 中的多个同名字段
- python - 循环执行时遇到问题
- rust - 如何从使用 actix_web::HttpRequest 获取 json 到结构中?