animation view click

 private boolean containPoint(View view, float x, float y) {
        Rect rect = new Rect();
        view.getHitRect(rect);
        
        Transformation trans = new Transformation();
        Animation anim = view.getAnimation();
        anim.getTransformation(view.getDrawingTime(), trans);
        
        float dx = view.getLeft();
        float dy = view.getTop();
        Matrix matTranslate = new Matrix();
        matTranslate.postTranslate(dx, dy);
        
        Matrix matrix = trans.getMatrix();
        matrix.postConcat(matTranslate);
        
        // 求逆矩阵
        Matrix mat = new Matrix();
        if (matrix.invert(mat)) {
            float[] pointsSrc = new float[] { x, y };
            float[] pointsEnd = new float[] { 0, 0 };
            
            // Get the point in inverted matrix.
            mat.mapPoints(pointsEnd, pointsSrc);
            // Offset the point because we translate matrix which dx and dy before.
            x = pointsEnd[0] + dx;
            y = pointsEnd[1] + dy;
            x = (int)pointsEnd[0] + (int)dx;
            y = (int)pointsEnd[1] + (int)dy;
        }
        
        return rect.contains((int)x, (int)y);
    }
    
    protected Rect mapRect(Matrix matrix, Rect srcRect) {
        float[] values = new float[9];
        matrix.getValues(values);
        float scaleX = values[0];
        float scaleY = values[4];
        float left = srcRect.left + srcRect.width() * (1 - scaleX) / 2;
        float top = srcRect.top + srcRect.height() * (1 - scaleY) / 2;
        float right = srcRect.top - srcRect.width() * (1 - scaleX) / 2;
        float bottom = srcRect.bottom - srcRect.height() * (1 - scaleY) / 2;
        
        Rect rect = new Rect((int)left, (int)top, (int)right, (int)bottom);
        return rect;
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在uniapp中,可以使用scroll-view组件来实现滚动到底部的功能。可以通过设置scroll-into-view属性或scroll-top属性来实现。 - 使用scroll-into-view属性: 您可以在scroll-view组件上设置scroll-into-view属性,将其绑定到一个具有相应id的组件上,以使scroll-view滚动到特定的组件位置。例如,在scroll-view上设置scroll-into-view="bottomId",其中bottomId是一个变化的id值,可以与要滚动到的组件的id值相对应。同时,还需要确保scroll-view具有明确的高度。这种方法可以在H5上有效。 - 使用scroll-top属性: 另一种方法是使用scroll-top属性来实现。您可以在scroll-view组件上设置scroll-top属性,将其绑定到一个变量scrollTopHeight上。通过更改该变量的值,可以将scroll-view滚动到指定的高度。同样,需要确保scroll-view具有明确的高度。这种方法在微信小程序上也有效。 例子代码如下: ```html <scroll-view scroll-y="true" style="height: 400rpx;" :scroll-into-view="bottomId" scroll-with-animation="true"> <view v-for="(item,index) in list"> <view :style="'height: 180rpx; background-color:' + item.color"></view> </view> <view :id="'p' + list.length">底部</view> </scroll-view> ``` 或 ```html <scroll-view scroll-y="true" style="height: 400rpx;" :scroll-top="scrollTopHeight" scroll-with-animation="true"> <view v-for="(item,index) in list"> <view :style="'height: 180rpx; background-color:' + item.color"></view> </view> </scroll-view> ``` 请注意,使用scroll-into-view或scroll-top属性时,需要确保scroll-view组件具有明确的高度,并且相应的id或变量值与要滚动到的组件一致。此外,在更改scroll-top属性值时,您可以使用setTimeout方法来延迟更改变量的值,以确保页面渲染完成后再滚动。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [uniapp关于scroll-view一直自动滚动到底部的功能](https://blog.csdn.net/u010513497/article/details/120321441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值