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

相关推荐
雨白2 小时前
深入理解 Kotlin 协程 (二):万剑归宗,揭秘 Kotlin 协程的精妙取舍
kotlin
程序员陆业聪3 小时前
你的 Android App 可能白白损失了 35% 的性能——R8 全模式配置详解
android
海兰7 小时前
【实战】MCP 服务在 Nacos 中注册状态分析与优化
android·java·github·银行系统·银行ai
bearpping7 小时前
MySQL压缩版安装详细图解
android·mysql·adb
代码改善世界8 小时前
【matlab初阶】matlab入门知识
android·java·matlab
huwuhang10 小时前
支付宝 APP 谷歌商店版 googleplay版最新
android
User_芊芊君子10 小时前
别再乱用 ArrayList 了!这 4 个隐藏坑,90% 的 Java 开发者都踩过
android·java·数据库
冬天vs不冷10 小时前
为什么 Java 不让 Lambda 和匿名内部类修改外部变量?final 与等效 final 的真正意义
android·java·开发语言
hogenlaw12 小时前
Stream流
android·java·开发语言
常利兵13 小时前
解锁Kotlin:数据类与密封类的奇妙之旅
android·开发语言·kotlin