负marginTop在Android上无法正常工作,在iOS上也可以正常工作

负marginTop在Android上无法正常工作,在iOS上也可以正常工作,android,react-native,layout,margin,Android,React Native,Layout,Margin,iOS和Android模拟器的示例 代码: 有人知道为什么会发生这种情况吗?谢谢大家! 负边距在Android上不起作用,因为上的默认溢出设置为hidden 修复方法是使用react native view overflow库,而不是。这将允许您像预期的那样使用负利润率 一旦添加到package.json文件中,您需要稍微调整项目以使其正常工作 在android/gradle/wrapper/gradle wrapper.properties中 -distributionUrl=https\

iOS和Android模拟器的示例

代码:


有人知道为什么会发生这种情况吗?谢谢大家!

负边距在Android上不起作用,因为
上的默认溢出设置为
hidden

修复方法是使用react native view overflow库,而不是
。这将允许您像预期的那样使用负利润率

一旦添加到
package.json
文件中,您需要稍微调整项目以使其正常工作

在android/gradle/wrapper/gradle wrapper.properties中

-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
在android/build.gradle中:

buildscript {
     repositories {
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.1.0'

     // NOTE: Do not place your application dependencies here; they belong
     // in the individual module build.gradle files
     compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    buildToolsVersion "27.0.3"
     defaultConfig {
为了删除警告,在android/app/build.gradle中:

buildscript {
     repositories {
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.1.0'

     // NOTE: Do not place your application dependencies here; they belong
     // in the individual module build.gradle files
     compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    buildToolsVersion "27.0.3"
     defaultConfig {

运行android,你就可以开始了

     compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    buildToolsVersion "27.0.3"
     defaultConfig {