java - 在 Android 中将图像宽度和高度设置为其原始值的 50%
问题描述
我是 Flutter 开发人员,没有原生 Android 方面的经验。
我需要启动画面的图像是其大小的 50%。
假设图像分辨率为 120x120px,我希望它显示为 60x60px。
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item>
</layer-list>
解决方案
如果您使用 API>23 并且虽然位图没有宽度和高度参数,您可以使用重力和项目宽度/高度来设置位图大小。
<item
android:width="60dp"
android:height="60dp">
<bitmap
android:gravity="fill_horizontal|fill_vertical"
android:src="@mipmap/launch_image" />
</item>
推荐阅读
- mysql - 在字符串中查找子字符串但不遵循命令
- c - 我应该使用哪个占位符,为什么?
- smb - SMB 访问掩码 - MAXIMUM_ALLOWED 与 GENERIC_ALL
- r - 从 Twitter 中提取推文
- javascript - amCharts 5:是否可以旋转轴刻度标签?
- docker - PyCharm Comm 2021.2 中的远程 python 解释器设置
- html - 为什么我的 div 排序在此 Bootstrap 页面中颠倒了?
- arrays - 赋值给数组类型的表达式时出错
- python - 在 Django 中发送发布请求后,如何使字段只读?
- swiftui - 如何将 SwiftUI TextField 中的换行符转义序列“\n”处理为换行符?