【一站式学会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 对比

相关推荐
plainGeekDev23 分钟前
ButterKnife → ViewBinding
android·java·kotlin
成都大菠萝14 小时前
Android Car CarProperty 车辆信号链路
android
敲代码的鱼14 小时前
PDF 预览与签名批注写回 支持安卓 iOS 鸿蒙 UTS插件
android·前端·ios
时光足迹16 小时前
uni-app 视频通话实战:康复师与患者视频问诊的 6 个致命 Bug 与解决方案
android·ios·uni-app
Coffeeee20 小时前
闲聊几句,Android老哥们,你们多久没做技改需求了
android·程序员·代码规范
萝卜er21 小时前
Fragment 生命周期与状态恢复-《Android深水区(四)》
android
萝卜er21 小时前
Intent 显式、隐式与 PendingIntent-《Android深水区(五)》
android
Kapaseker1 天前
一文吃透 Kotlin 集合操作符
android·kotlin
三少爷的鞋1 天前
Main-safe:现代Android 架构真正的分水岭
android
沐怡旸1 天前
深入解析 Android Performance Analyzer (APA) 底层架构与技术原理
android