简体   繁体   English

ReactNative:从DrawerLayoutAndroid移除阴影

[英]ReactNative : Remove shadow from DrawerLayoutAndroid

Is there a way to accomplish this : 有没有办法做到这一点:

Android Remove Shadow On Navigation Drawer Android在导航抽屉上删除阴影

in React Native ? 在React Native中?

I see no properties for doing that in the DrawerLayoutAndroid documentation 我在DrawerLayoutAndroid文档中没有看到执行此操作的属性

You are right in that the RN API does not offer a way to parametrize that property, but the DrawerLayoutAndroid component extends from the native DrawerLayout , and so you can just tweak a bit the source code to include the desired functionality. 没错,RN API没有提供参数化该属性的方法,但是DrawerLayoutAndroid组件是从本机DrawerLayout扩展的,因此您可以稍微调整一下源代码以包含所需的功能。 Have a look here and here . 在这里这里看看。

Of course, messing around with RN's code might be a bit messy, so what you can do is just take those files and refactor them into a separate component that extends your functionality. 当然,弄乱RN的代码可能会有些混乱,因此您所要做的就是获取这些文件并将它们重构为一个单独的组件,以扩展您的功能。 I built such component and put it in a repo so that you can have a look. 我构建了这样的组件并将其放入回购中,以便您查看。 Here's the link: https://github.com/martinarroyo/DrawerLayoutNoShadow Particularly have a look at this line . 这里是链接: https : //github.com/martinarroyo/DrawerLayoutNoShadow特别是看看这一行

I set the value to transparent, but you can put any other color you'd like and it should work. 我将值设置为透明,但是您可以放置​​任何其他颜色,它应该可以工作。 A very good idea would be to pass the value as a prop , but the essentials should be covered with the code in the repo. 一个很好的主意是将值作为prop传递,但是要点应该由回购中的代码覆盖。

Hope that helps. 希望能有所帮助。

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

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