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

相关推荐
91刘仁德1 小时前
C++ 内存管理
android·c语言·数据结构·c++·经验分享·笔记·算法
小强开学前1 小时前
自定义 Drawable 实现任意高度纯圆角背景及玻璃效果
android
秃了也弱了。2 小时前
ElasticSearch:优化案例实战解析(持续更新)
android·java·elasticsearch
恋猫de小郭2 小时前
Kotlin 在 2.0 - 2.3 都更新了什么特性,一口气带你看完这两年 Kotlin 更新
android·前端·flutter
墨狂之逸才3 小时前
React Native 移动项目目录导致的 Android 编译失败问题及解决方案
android·react native
feng一样的男子3 小时前
住在手机里的“小龙虾” (OpenClaw):接入本地模型,解决记忆“装死”顽疾
android·ai·智能手机·openclaw
hongtianzai3 小时前
MySQL中between and的基本用法
android·数据库·mysql
Zender Han4 小时前
Flutter Bloc / Cubit 最新详解与实战指南(2026版)
android·flutter·ios
sun0077005 小时前
pthread_once
android
阿拉斯攀登6 小时前
第 20 篇 RK 平台 NPU / 硬件编解码驱动适配与安卓调用
android·驱动开发·瑞芯微·rk安卓驱动