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

相关推荐
浮江雾几秒前
Flutter第十节-----Flutter布局与组件全解析
android·开发语言·前端·学习·flutter·入门
Jomurphys29 分钟前
Compose 适配 - 自适应布局(窗口大小类 WindowSizeClasses、列表详情、辅助窗格)
android·compose
plainGeekDev1 小时前
synchronized → Coroutines
android·java·kotlin
sun0077002 小时前
gtest 行覆盖率、函数覆盖率、分支覆盖率 . 一般这3个要达到多少?算达标
android
施棠海2 小时前
设计稿一键变成可运行的Android页面:Pixel2XML全流程UI开发框架实战(附完整源码)
android·ui·架构
Jomurphys2 小时前
Compose 适配 - 分辨率(密度)
android·compose
__Witheart__2 小时前
获取产品对应文件夹
android
__Witheart__3 小时前
版型关联的设备树查询方式
android·rockchip
浪客川3 小时前
Android的SystemUI的启动流程简析
android·开发语言
世界尽头与你3 小时前
Android Root 检测原理
android·安全·网络安全·渗透测试