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

相关推荐
GEEKVIP6 分钟前
手机使用技巧:8 个 Android 锁屏移除工具 [解锁 Android]
android·macos·ios·智能手机·电脑·手机·iphone
model20052 小时前
android + tflite 分类APP开发-2
android·分类·tflite
彭于晏6892 小时前
Android广播
android·java·开发语言
与衫3 小时前
掌握嵌套子查询:复杂 SQL 中 * 列的准确表列关系
android·javascript·sql
500了9 小时前
Kotlin基本知识
android·开发语言·kotlin
人工智能的苟富贵10 小时前
Android Debug Bridge(ADB)完全指南
android·adb
小雨cc5566ru15 小时前
uniapp+Android面向网络学习的时间管理工具软件 微信小程序
android·微信小程序·uni-app
bianshaopeng16 小时前
android 原生加载pdf
android·pdf
hhzz16 小时前
Linux Shell编程快速入门以及案例(Linux一键批量启动、停止、重启Jar包Shell脚本)
android·linux·jar
火红的小辣椒17 小时前
XSS基础
android·web安全