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

相关推荐
️学习的小王32 分钟前
二级MySQL PHP综合应用题完整考点+历年真题风格练习题
android·mysql·php
YB137512 小时前
jetpack compose 副作用 SideEffect
android·kotlin
CHB14 小时前
uni-app x 蒸汽模式 性能测试基准报告 Benchmark【Android版】
android·ios·uni-app
带娃的IT创业者15 小时前
拆掉那堵墙:LibrePods 如何让 AirPods 在 Android 上重获新生
android·开源项目·airpods·librepods·生态解锁
_阿南_16 小时前
flutter 展示的字体突然奔放了
android·flutter·ios
文人sec19 小时前
MySQL事务与索引做了什么?
android·笔记·mysql
刘洋浪子20 小时前
AndroidStudio保存日志菜单
android
朱涛的自习室20 小时前
从 Prompt 到 Graph:AI 工程的进化史
android·前端·人工智能
2501_9327502621 小时前
Android 中 Serializable 与 Parcelable 的对比与选择
android
FungLeo1 天前
Flutter 两个反直觉布局坑:ListTile 水波纹 / VerticalDivider 踩坑实录
android·flutter