set button in position “fixed” in React Native

2020-08-16 03:56发布

I would like set button on the bottom right corner width fixed position in React Native.

position: fixed don't work in React Native and stickyHeaderIndices method in ScrollView does not allow to position an element above the others component.

Anyone have already test this feature ?

4条回答
仙女界的扛把子
2楼-- · 2020-08-16 04:08

Try this:

render() {
    return (
      <View style={{flex:1}}>
        <View style={{borderWidth:1,position:'absolute',bottom:0,alignSelf:'flex-end'}}>
           <Button
             title="Press"
             color="#841584"
             accessibilityLabel="Press"/>
        </View>
      </View>
    );
  }

Output:

enter image description here

查看更多
疯言疯语
3楼-- · 2020-08-16 04:09

Just put the component outside of the scrollview and set it with position absolute

查看更多
We Are One
4楼-- · 2020-08-16 04:17
<View style={{flex: 1}}>
    <ScrollView style={{backgroundColor:'yellow'}}>
          <Text>body</Text>
    </ScrollView>
    <View><Text>sticky footer</Text></View>
</View>
查看更多
可以哭但决不认输i
5楼-- · 2020-08-16 04:23

If you are using Native Base you can just use the Footer Component

查看更多
登录 后发表回答