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

相关内容

热门资讯

2026版方法!we-poke... 2026版方法!we-poker正规吗,智星菠萝透视,确实确实有挂(竟然有挂)1、智星菠萝透视辅助器...
今日重大通报!德州私人局脚本,... 今日重大通报!德州私人局脚本,aa poker辅助,切实是真的有挂(有挂技巧)1、辅助软件下载优化,...
刚刚!wepoker免费透视,... 刚刚!wepoker免费透视,德扑软件,切实确实有挂(有挂方式)在进入德扑软件软件靠谱后,参与本局比...
我来教教你!约局吧作弊脚本,智... 我来教教你!约局吧作弊脚本,智星德州有脚本吗,果然真的有挂(有挂功能)1、免费脚本咨询教程、免费脚本...
现有关情况通报如下!wepok... 现有关情况通报如下!wepoker如何设置透视,德扑之星怎么设置埋牌,好像存在有挂(有挂总结)1、金...
揭秘攻略!wpk辅助是什么,a... 揭秘攻略!wpk辅助是什么,aapoker脚本怎么用,果然有挂(有挂教学)辅助器是一种具有地方特色的...
技巧辅助挂!wepoker游戏... 技巧辅助挂!wepoker游戏的安装教程,德扑之星辅助工具如何打开,本来真的是有挂(有挂秘诀)德扑之...
分享实测!wepoker挂,h... 分享实测!wepoker挂,hhpoker辅助,一贯是有挂(确实有挂)1)有没有挂:进一步探索有辅助...
近期!wepoker私局辅助,... 近期!wepoker私局辅助,德普之星怎么开辅助,本来存在有挂(有挂方法)1、德普之星怎么开辅助免费...
玩家必知教程!wepoker辅... 玩家必知教程!wepoker辅助是真的吗,hhpoker是内部控制吗,竟然真的是有挂(有挂方略)1、...