react-native: [Android] skew transform not working

Steps To Reproduce

  1. Try to set skewX for View component: transforms: [{ skewX: '45deg' }}
  2. Doesn’t change the skew of View on Android (works on iOS)

Describe what you expected to happen:

Basically skewX doesn’t apply any skew on the view on Android. Here is comparison between iOS/Android:

also skewY doesn’t render same as on iOS (which looks more correct) Screenshot 2020-01-02 at 2 13 00 PM

React Native version:

System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.50 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 25, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

Related issues

Snack demo

https://snack.expo.io/@usrbowe2/e9b920

Resources

In case anyone interested, here is the source code for skew code:

  1. This is called for SkewX: MatrixMathHelper.applySkewX(helperMatrix, convertToRadians(transform, transformType)); in file: Libraries/StyleSheet/processTransform.js
  2. Which laters uses this matrix helper to apply transformation: https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/uimanager/MatrixMathHelper.java

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 24
  • Comments: 30 (1 by maintainers)

Commits related to this issue

Most upvoted comments

This is real problem!

Version 0.70.5, skewX still doesn’t work

For images I just recreated it by myself: I croped 100 same images with ImageEditor and aligned each part in offset to create the one I needed…

A live preview of this issue can be found at the example in https://deploy-preview-1613--react-native.netlify.com/docs/next/transforms

still not wroking… any solution ?

@kelset it still happens.

This is when using skewX on android (nothing happens): image

and this is when happens when using skewY on android (as visible, the view is not skewed, but instead, rotated): image

Btw: This IS on RN 65 RC2

skewX and skewY are not working on android mobile phones. But it works only in IOS.

I use transform: [{ skewX: '45deg' }].

I can see that skew style rules are still not working correctly on Android with RN v0.64.2.

Even the example provided on the transforms documentation page doesn’t work:

anroid-skew-not-working

However it works on iOS as described in the original issue:

ios-skew-working

Can we reopen this issue as it seems like the applied fix didn’t resolve the reported issue?

2024 and still same issue 😦

One solution can be to use a combination of rotates (x,y,z) to produce a similar effect.

It will not be exactly similar to Skew but with some trial and error we can produce something similar.

Eg. <View style={{ transform: [ { rotateZ: “345deg” } ] }}> <View style={[styles.box, { transform: [ { rotateX: “30deg” }, { rotateY: “330deg” }, { rotateZ: “30deg” } ] }]}> <Text style={styles.text}>Rotate X,Y,Z (similar to skew)</Text> </View> </View>