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

相关推荐
不爱说话郭德纲12 小时前
告别漫长的HbuilderX云打包排队!uni-app x 安卓本地打包保姆级教程(附白屏、包体积过大排坑指南)
android·前端·uni-app
Sinclair16 小时前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
雮尘20 小时前
手把手带你玩转Android gRPC:一篇搞定原理、配置与客户端开发
android·前端·grpc
ktl21 小时前
Android 编译加速/优化 80%:一个文件搞定,零侵入零配置
android
alexhilton1 天前
使用FunctionGemma进行设备端函数调用
android·kotlin·android jetpack
冬奇Lab1 天前
InputManagerService:输入事件分发与ANR机制
android·源码阅读
张小潇2 天前
AOSP15 Input专题InputManager源码分析
android·操作系统
RdoZam2 天前
Android-封装基类Activity\Fragment,从0到1记录
android·kotlin
奥陌陌2 天前
android 打印函数调用堆栈
android
用户985120035832 天前
Compose Navigation 3 深度解析(二):基础用法
android·android jetpack