简体   繁体   English

在 Android 中向网络视图或相机添加叠加层

[英]Add an overlay to web view or camera in Android

Consider the following, minimal JSX example for react-native:考虑以下用于 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>

Run on iOS or the Android emulator, this will show a blue rectangle on the red WebView .在 iOS 或 Android 模拟器上运行,这将在红色WebView上显示一个蓝色矩形。 On my Android devices, the blue rectangle won't show up.在我的 Android 设备上,蓝色矩形不会出现。

Is this a general limitation of the way controls work in Android or is there a way to make this rectangle show up on actual Android devices?这是控件在 Android 中工作方式的一般限制,还是有办法让这个矩形显示在实际的 Android 设备上? Currently I don't have any clue on how to debug this issue ...目前我对如何调试这个问题没有任何线索......

Replacing the WebView with a simple View , this will work on Android devices as well.用简单的View替换WebView ,这也适用于 Android 设备。

This will solve your problem.这将解决您的问题。

Use RelativeLayout with 2 views in it one overlay and other one web view.Both view will overlap each other.使用具有 2 个视图的 RelativeLayout 一个覆盖和另一个 Web 视图。两个视图将相互重叠。 And you will get the effect you want to have.你会得到你想要的效果。

<RelativeLayout>
   <WebView>
    //here webview
   </Webview>
   <ImageView>
    //here the overlay
   <ImagView>
</RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM