react-native 踩到坑之 transform skewX skewY

来源:互联网 发布:数据价值网 邹志飞 编辑:程序博客网 时间:2024/06/10 17:19

提示,本文不能解决问题,但作为一个坑的记录,经验教训

rn版本 0.46

众所周知,transform是用来变换视图的属性,

经实践,transform各个属性在ios平台上运行良好,安卓上的表现与ios不一致。


比较严重的是在安卓上skewX、skewY比较扯蛋,skewX不能用,skewY居然是旋转效果……

经探索谷歌、github,发现,此问题可能暂时得不到解决,rn代码贡献者MaxGraey提到:

I confirm, for Android skew transform is not working.

我确认,无法工作

Digging deep in ReactAndroid's sources I found the following:

Code to transform the view is made very inefficient. In order to apply transformation matrix firstly decompose to scale/rotate/skew/translation and applied separately to view.setTranslationX, view.setTranslationY and etc.

Android's view does't has methods for setSkewX and setSkewY at all. "setMatrix" absent as well!

So I see only two ways:

    1. Use view's setAnimationMatrix.
    2. Subclassing View to obtain direct access to private mRenderNode and his matrix property.
Both way need hard refactoring existing code
看来只有两种方法:
1.设定视图的动画矩阵功能
2.继承视图,获得私有的mRenderNode节点并用它的矩阵属性

大神提到,两种方法都很困难。

skewX skewY 这个坑绕过吧。用rotate等多个拼合的方法代替。

原创粉丝点击