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

相关推荐
Be for thing5 分钟前
Android 蓝牙 & WiFi 硬件原理 + 功耗与异常定位实战(手机 / 手表 / IoT 通用)
android·物联网·学习
00后程序员张23 分钟前
使用克魔助手(Keymob)查看 iOS 设备日志与崩溃报告
android·macos·ios·小程序·uni-app·cocoa·iphone
__Yvan1 小时前
解决ConstraintLayout中LinearLayout显示异常问题
android·xml·约束布局
mjhcsp1 小时前
C++ A* 算法:启发式路径搜索的黄金标准
android·c++·算法
2501_915918411 小时前
通过IPA 结构调整和资源指纹变化来处理 iOS 应用相似度问题
android·ios·小程序·https·uni-app·iphone·webview
火山上的企鹅1 小时前
Qt/QGroundControl 实战:接入 Skydroid(云卓) G20 遥控器 Android SDK 并实时显示摇杆与信号质量
android·开发语言·qt·qgroundcontrol·云卓sdk
Be for thing2 小时前
Android 屏幕硬件原理 + 显示驱动与功耗优化实战(手机 / 手表通用)
android·学习·智能手机
冰语竹2 小时前
滚动视图HorizontalScrollView和ScrollView
android
studyForMokey2 小时前
【跨端技术ReactNative】JavaScript学习
android·javascript·学习·react native·react.js
Be for thing2 小时前
Android 充电 & BMS 电池管理系统原理与测试实战(手机 / 手表通用)
android·学习·智能手机