【一站式学会compose】 Android UI体系之 Image的使用和介绍

(1)Image图片组件是用来显示一张图片的

Image参数介绍

kotlin 复制代码
fun Image(
    painter: Painter, /// 图片资源
    contentDescription: String?, // 图片描述
    modifier: Modifier = Modifier, // 修饰符
    alignment: Alignment = Alignment.Center,// 位置
    contentScale: ContentScale = ContentScale.Fit,// 缩放
    alpha: Float = DefaultAlpha,// 透明度
    colorFilter: ColorFilter? = null // 颜色修改
)

(2)Image的使用

kotlin 复制代码
 Image(
        painterResource(R.drawable.im),
        contentDescription = "一张图片"
    )

(3)重要参数讲解:ContentScale。参数说明:

基础语法:

kotlin 复制代码
Image(
    painterResource(R.drawable.im),
    contentDescription = "一张图片",
    contentScale = ContentScale.Inside
)

(4)与Android ImageView scaleType 对比

相关推荐
BoomHe1 天前
Android AOSP13 原生 Launcher3 壁纸获取方式
android
Digitally1 天前
如何将联系人从 Android 转移到 Android
android
李小枫1 天前
webflux接收application/x-www-form-urlencoded参数
android·java·开发语言
爱丽_1 天前
MySQL `EXPLAIN`:看懂执行计划、判断索引是否生效与排错套路
android·数据库·mysql
NPE~1 天前
[App逆向]环境搭建下篇 — — 逆向源码+hook实战
android·javascript·python·教程·逆向·hook·逆向分析
yewq-cn1 天前
AOSP 下载
android
cch89181 天前
Laravel vs ThinkPHP:PHP框架终极对决
android·php·laravel
米码收割机1 天前
【Android】基于安卓app的汽车租赁管理系统(源码+部署方式+论文)[独一无二]
android·汽车
流星雨在线1 天前
安卓使用 Startup 管理三方 SDK 初始化
android·startup
jwn9991 天前
Laravel3.x:PHP框架的经典里程碑
android