首页 文章

在React Native中将按钮设置为“固定”

提问于
浏览
3

我想在React Native中设置右下角宽度固定位置的按钮 .

position: fixed 在React Native中不起作用,ScrollView中的 stickyHeaderIndices 方法不允许将元素放在其他组件上方 .

有人已经测试过这个功能吗?

2 回答

  • 3

    试试这个:

    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>
        );
      }
    

    输出:

    enter image description here

  • 1
    <View style={{flex: 1}}>
        <ScrollView style={{backgroundColor:'yellow'}}>
              <Text>body</Text>
        </ScrollView>
        <View><Text>sticky footer</Text></View>
    </View>
    

相关问题