简体   繁体   English

react-native 中的小底页问题

[英]Small Bottom Sheet Issue in react-native

我在页面中使用了 3/4 大小的 bottomSheet,再次在相同 3/4 大小的底页页面中打开 1/4 大小的底页(第一个底页没有关闭)

It is better to use the framework with its full potential.最好使用具有全部潜力的框架。 As official documentation states for method setFitToContents :正如方法 setFitToContents 的官方文档所述:

Sets whether the height of the expanded sheet is determined by the height of its contents, or if it is expanded in two stages (half the height of the parent container, full height of parent container).设置展开的工作表的高度是由其内容的高度决定,还是分两个阶段展开(父容器的一半高度,父容器的全高)。 Default value is true.默认值为真。

So all you need is set setFitToContent to false with:因此,您只需将 setFitToContent 设置为 false :

behavior = BottomSheetBehavior.from(your_bottom_sheet_xml)
behavior.isFitToContents = false
behavior.halfExpandedRatio = 0.6f

With this 3-line-code the bottom sheet will expand till 60% of the screen at first, and afterwards it will fully expand to 100%.使用这个 3 行代码,底部表格将首先扩展至屏幕的 60%,然后将完全扩展至 100%。

Hope it can help someone!希望它可以帮助某人!

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

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