android - 如何在启动画面中心设置徽标?
问题描述
我正在尝试在 dp 中有一个以 layout_width 和 layout_height 为中心的徽标图像启动画面。徽标图像直接从位于 的徽标文件夹中获取@mipmap/ic_launcher
。
问题: 我无法将徽标图像居中。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/launch_background"
>
<ImageView
android:src="@mipmap/ic_launcher"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
>
</ImageView>
</FrameLayout>
解决方案
您可以将其添加android:layout_gravity="center"
到您ImageView
的中心FrameLayout
:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/launch_background"
>
<ImageView
android:src="@mipmap/ic_launcher"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:scaleType="centerCrop"
>
</ImageView>
</FrameLayout>
推荐阅读
- java - 一个接一个的放置JPanel就是隐藏之前附加的JPanel
- c# - 为什么 Audit.NET 为 AuditContext 获取本地 DbContext 以记录数据
- java - Java中的构造函数链接和超级关键字
- presto - EMR Presto LDAPS:未加载身份验证器
- react-native - 流式传输 RTMP 与覆盖,反应原生
- firebase - Flutter:- already_active,图像选择器已经激活,null,null
- c# - 如何制作输出:1 1 2 6 3 11 4 16 5 21
- c - 如何在 Contiki Cooja 模拟器上访问 RPL 的 DIO 消息?
- python - 数据框 - 在列中查找常用短语
- javascript - Firebase Cloud Function:即使数据在 Cloud Firestore 中,Cloud Firestore 查询也无效