简体   繁体   English

如何在本机反应中使按钮粘在ScrollView内的底部?

[英]How to make button sticky to the bottom inside ScrollView in react native?

As per the solution given on other answers, to place the sticky content outside the scrollview.根据其他答案给出的解决方案,将粘性内容放在滚动视图之外。 But when I am placing sticky button outide the scrollview and when the soft keyboard popsup, the sticky button pops-up to the top of content as it is not inside scrollView.但是,当我将粘性按钮放在滚动视图之外并且软键盘弹出时,粘性按钮会弹出到内容的顶部,因为它不在滚动视图内。 Ideally button should stick to the bottom even after keyboard pops-up ie it should be behind the keyboard.理想情况下,即使在键盘弹出后按钮也应该粘在底部,即它应该在键盘后面。 Please check video in the attached URL.请查看随附的 URL 中的视频。

https://filebin.net/e7ek1zkt9840f9lw https://filebin.net/e7ek1zkt9840f9lw

Related snack is:相关小吃是:

https://snack.expo.io/qtTC4tvTE https://snack.expo.io/qtTC4tvTE

You can use stickyHeaderIndices props to ScrollView.您可以对 ScrollView 使用stickyHeaderIndices 道具。 consider your structure is as follows:考虑你的结构如下:

     <ScrollView> 
       <View><Text>This is header</Text></View>
       <View><Text>This is body</Text></View>
       <View><Text>This is footer</Text></View>
     </ScrollView>

and if you want to make your footer part sticky then simply put stickyHeaderIndices={[2]} inside scrollview.如果你想让你的页脚部分变得粘稠,那么只需将 stickyHeaderIndices={[2]} 放在滚动视图中。

      <ScrollView stickyHeaderIndices={[2]}> 
       <View><Text>This is header</Text></View>
       <View><Text>This is body</Text></View>
       <View><Text>This is footer</Text></View>
     </ScrollView>

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

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