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

相关推荐
峥嵘life1 小时前
Android16 EDLA 认证测试CTS问题分析解决
android·java·服务器
惟恋惜1 小时前
Jetpack Compose 的状态使用之“界面状态”
android·android jetpack
_李小白3 小时前
【Android FrameWork】第二十六天:BroadcastReceiver
android
@#---4 小时前
如何准确判断json文件并且拿到我想要的信息
android·python·json
KotlinKUG贵州5 小时前
Kotlin/Ktor 实践:利用 MCP 从零打造 AI Agent 服务端指南
kotlin·agent·mcp
喜熊的Btm6 小时前
探索 Kotlin 的不可变集合库
kotlin·android jetpack
程序员陆业聪6 小时前
Android插件化原理与方案详解
android
惟恋惜8 小时前
Jetpack Compose 界面元素状态(UI Element State)详解
android·ui·android jetpack
_李小白9 小时前
【Android FrameWork】延伸阅读:IGraphicBufferProducer驱动UI绘制过程
android·ui
_李小白10 小时前
【Android FrameWork】第二十八天:Activity 的 UI 绘制全过程
android·ui