不同的中心点旋转ImageView
创始人
2025-01-08 21:30:38
0

要实现不同的中心点旋转ImageView,可以通过自定义ImageView来实现。下面是一个示例代码:

  1. 创建一个自定义的ImageView类,命名为RotateImageView:
public class RotateImageView extends ImageView {

    private float centerX;
    private float centerY;
    private float rotation;

    public RotateImageView(Context context) {
        super(context);
    }

    public RotateImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public RotateImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.rotate(rotation, centerX, centerY);
        super.onDraw(canvas);
    }

    public void setRotation(float rotation) {
        this.rotation = rotation;
        invalidate();
    }

    public void setCenter(float centerX, float centerY) {
        this.centerX = centerX;
        this.centerY = centerY;
        invalidate();
    }
}
  1. 在布局文件中使用RotateImageView:

  1. 在代码中使用RotateImageView并设置不同的中心点和旋转角度:
RotateImageView imageView = findViewById(R.id.imageView);
imageView.setCenter(imageView.getWidth() / 2, imageView.getHeight() / 2); // 设置中心点为ImageView的中心
imageView.setRotation(45); // 设置旋转角度为45度

通过设置不同的中心点和旋转角度,即可实现不同的中心点旋转ImageView效果。

相关内容

热门资讯

透视挂透视!wepoker辅助... 透视挂透视!wepoker辅助器是真的吗,哈糖大菠萝免费辅助器,妙招教程(总是真的有挂)-哔哩哔哩1...
透视教学!pokemmo手机版... 透视教学!pokemmo手机版脚本免费,aapoker万能辅助器,模块教程(本来真的是有挂)-哔哩哔...
透视线上!wepoker可以开... 透视线上!wepoker可以开透视吗,wepoker有用吗,教材教程(总是存在有挂)-哔哩哔哩1.w...
透视讲解!hhpoker德州牛... 透视讲解!hhpoker德州牛仔视频,hhpoker有透视功能吗,步骤教程(总是有挂)-哔哩哔哩1、...
透视系统!wejoker免费脚... 透视系统!wejoker免费脚本,wpk辅助是真的吗,项目教程(果然是真的挂)-哔哩哔哩;1、wpk...
透视工具!wpk俱乐部有没有辅... 透视工具!wpk俱乐部有没有辅助,aapoker怎么选牌,教程书教程(真是有挂)-哔哩哔哩1、下载好...
透视工具!wepoker辅助分... 透视工具!wepoker辅助分析器,wpk显示有辅助,方针教程(本来是真的挂)-哔哩哔哩1、该软件可...
透视透视!如何下载wepoke... 透视透视!如何下载wepoker安装包,wepoker有没有插件,练习教程(本来是真的挂)-哔哩哔哩...
透视模拟器!aapoker辅助... 透视模拟器!aapoker辅助器是真的吗,wepoker有人用过吗,大纲教程(一贯存在有挂)-哔哩哔...
透视中牌率!wepokerpl... 透视中牌率!wepokerplus辅助,德州透视插件,策略教程(确实是真的挂)-哔哩哔哩1)德州透视...