不同的中心点旋转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效果。

相关内容

热门资讯

一分钟了解!hhpoker是正... 一分钟了解!hhpoker是正品吗,wepoker破解器激活码,总是是有挂(存在有挂)进入游戏-大厅...
推荐十款!hhpoker是真的... 推荐十款!hhpoker是真的吗,wpk辅助软件,切实有挂(有挂方式)暗藏猫腻,小编详细说明破解器有...
总算了解!pokermaste... 总算了解!pokermaster脚本,德普辅助app,都是真的有挂(有挂秘诀)1、游戏颠覆性的策略玩...
详细说明!wepoker作弊辅... 详细说明!wepoker作弊辅助,hhpoker有透视功能吗,确实是有挂(有挂方针)1、公共底牌简单...
大神推荐!wepoker透视脚... 大神推荐!wepoker透视脚本,wpk软件是真的吗,真是存在有挂(存在有挂)大神推荐!wepoke...
盘点十款!wpk有辅助器吗,w... 盘点十款!wpk有辅助器吗,wpk辅助插件,果然有挂(有挂教学)1、盘点十款!wpk有辅助器吗,wp...
发现一款!德普之星透视辅助,w... 发现一款!德普之星透视辅助,we-poker靠谱吗,切实存在有挂(真的有挂)1、玩家可以在透视最简单...
重要通知!aapoker如何设... 重要通知!aapoker如何设置胜率,wejoker内置辅助,确实是有挂(有挂存在)1、玩家可以在线...
玩家实测!wejoker辅助软... 玩家实测!wejoker辅助软件视频,如何下载wepoker安装包,其实存在有挂(有挂讲解)破解侠是...
必备攻略!微扑克辅助下载,wp... 必备攻略!微扑克辅助下载,wpk辅助哪里买,好像真的是有挂(果真有挂)1、用户打开应用后不用登录就可...