首页 > 解决方案 > 如何在 React Native 中将视图相互叠加以实现与 Android 原生中的 FrameLayout 相同的效果

问题描述

[可能重复]

我正在尝试将视图放在另一个之上,并使用本机 Android 开发,例如,我将使用框架布局来实现这一点

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#b1945c"
    />

<View
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ccd1cc"
    android:layout_margin="50dp"
    />
</FrameLayout>

看起来像这样: 在此处输入图像描述

如何在 React Native 中实现相同的效果?

标签: react-native

解决方案


试试这个,

  <View style={{
        flex:1,
        backgroundColor:"#b1945c"
       }}>     
  <View 
    style={{
      margin:50,
      backgroundColor:"#ccd1cc"
         }}>
  </View>
 </View>

推荐阅读