Android ShapeableImageView rotation in Kotlin code

Android ShapeableImageView rotation in Kotlin code

Kotlin 复制代码
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import com.google.android.material.imageview.ShapeableImageView


class MyImageView(ctx: Context, attrs: AttributeSet?, defStyleAttr: Int) :
    ShapeableImageView(ctx, attrs, defStyleAttr) {
    private val TAG = "fly/${this::class.simpleName}"

    //init代码块相当于Java的static静态代码块。
    init {
        Log.d(TAG, "init")

        rotation = -30F //逆向旋转30°
        Log.d(TAG, "旋转 $rotation")
    }

    constructor(context: Context) : this(context, null, 0) {
        Log.d(TAG, "constructor-1")
    }

    constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) {
        Log.d(TAG, "constructor-2")
    }
}

Android官方ShapeableImageView描边/圆形/圆角图,xml布局实现-CSDN博客文章浏览阅读121次。Android RoundedBitmapDrawable:Android官方的圆角图形图象实现方案RoundedBitmapDrawable是Android在support v4的扩展包中新增的实现圆角图形的关键类,借助RoundedBitmapDrawable的帮助,可以轻松的以Android标准方式实现圆角图形图象。现在结合他人的代码加以修改,给出一个以原始图形中心为原点,修剪图片为头像的工具类,此类可以直接在布局文件中加载使用,比。https://blog.csdn.net/zhangphil/article/details/134031190

相关推荐
2501_9371549310 分钟前
酷秒神马 9.0 版源码系统实测
android·源码·源代码管理·机顶盒
r***113344 分钟前
【MySQL】MySQL库的操作
android·数据库·mysql
武子康1 小时前
AI研究-133 Java vs Kotlin/Go/Rust/Python/Node:2025 详细对比分析 定位与取舍指南
java·javascript·python·golang·rust·kotlin·node
ljt27249606611 小时前
Compose笔记(五十九)--BadgedBox
android·笔记·android jetpack
用户41659673693551 小时前
ExoPlayer 播放花屏与跳跃?我们如何像 QuickTime 一样优雅处理音频时间戳错误
android
Y***h1871 小时前
MySQL不使用子查询的原因
android·数据库·mysql
p***93031 小时前
Java进阶之泛型
android·前端·后端
3***16101 小时前
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
android·数据库·mysql
L***86531 小时前
MySQL中between and的基本用法、范围查询
android·数据库·mysql
p***95002 小时前
MySQL Workbench菜单汉化为中文
android·数据库·mysql