在 Android 中向网络视图或相机添加叠加层
Add an overlay to web view or camera in Android
考虑以下 react-native 的最小 JSX 示例:
<WebView style={{flex:1, backgroundColor: '#FF0000'}}>
<View style={{position: 'absolute', width: 30, height: 30, left: 10, top: 10, backgroundColor: '#0000FF'}}>
</View>
</WebView>
运行 在 iOS 或 Android 模拟器上,这将在红色 WebView
上显示蓝色矩形。在我的 Android 设备上,蓝色矩形不会显示。
这是控件在 Android 中工作方式的一般限制,还是有办法让这个矩形显示在实际的 Android 设备上?目前我不知道如何调试这个问题...
用简单的 View
替换 WebView
,这也适用于 Android 设备。
这将解决您的问题。
将 RelativeLayout 与其中的 2 个视图一起使用,一个叠加层和另一个 Web view.Both 视图将相互重叠。而且你会得到你想要的效果。
<RelativeLayout>
<WebView>
//here webview
</Webview>
<ImageView>
//here the overlay
<ImagView>
</RelativeLayout>
考虑以下 react-native 的最小 JSX 示例:
<WebView style={{flex:1, backgroundColor: '#FF0000'}}>
<View style={{position: 'absolute', width: 30, height: 30, left: 10, top: 10, backgroundColor: '#0000FF'}}>
</View>
</WebView>
运行 在 iOS 或 Android 模拟器上,这将在红色 WebView
上显示蓝色矩形。在我的 Android 设备上,蓝色矩形不会显示。
这是控件在 Android 中工作方式的一般限制,还是有办法让这个矩形显示在实际的 Android 设备上?目前我不知道如何调试这个问题...
用简单的 View
替换 WebView
,这也适用于 Android 设备。
这将解决您的问题。
将 RelativeLayout 与其中的 2 个视图一起使用,一个叠加层和另一个 Web view.Both 视图将相互重叠。而且你会得到你想要的效果。
<RelativeLayout>
<WebView>
//here webview
</Webview>
<ImageView>
//here the overlay
<ImagView>
</RelativeLayout>