CSS 在 React Native 的“固定”位置设置按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48188126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:49:55  来源:igfitidea点击:

set button in position "fixed" in React Native

cssreact-native

提问by s-leg3ndz

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

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

position: fixeddon't work in React Native and stickyHeaderIndicesmethod in ScrollView does not allow to position an element above the others component.

position: fixed在 React Native 中不起作用,并且stickyHeaderIndicesScrollView 中的方法不允许将元素定位在其他组件上方。

Anyone have already test this feature ?

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

回答by Himanshu Dwivedi

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

在此处输入图片说明

回答by Bashirpour

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

回答by SLIMANI Mohammed

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

如果您使用的是 Native Base,您可以只使用页脚组件

回答by Marco Antonio

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

只需将组件放在滚动视图之外并将其设置为绝对位置