React-Native 中的右下对齐(使用 Flex-box)不起作用

最大限度

制作待办事项列表类型的内容以添加到我的应用程序中,但是当尝试将“添加待办事项”按钮与右下角对齐时,该按钮会出现在除此之外的任何地方。

我很擅长 CSS,但在使用 React CSS/styles 时却很糟糕。我玩过不同的属性,给父母一个风格而不是孩子等等。

类如下

class AgendaScreen extends React.Component {
  addReminder = () => {
    //blank so far :)
  };

  render() {
    return (
      <View>
        <Text style={styles.titleStyle}>Agenda</Text>

        <View style={styles.reminderView}>
          <TouchableOpacity style={styles.reminderTouch}>
            <Text style={styles.reminderBtn}>+</Text>
          </TouchableOpacity>
        </View>
      </View>
    );
  }
}

和这里的风格

  //Agenda screen styles

  reminderView: {
    flex: 1,
    justifyContent: 'flex-end',
  },

  reminderTouch: {
    width: 60,
    height: 60,
    backgroundColor: 'orange',
    borderRadius: 100,
    textAlign: 'center',
    margin: 20,
  },

  reminderBtn: {
    fontSize: 50,
    margin: 10,

    alignSelf: 'flex-end',
  },

目标是将圆圈中间的加号对齐,并将该圆圈与右下角对齐。粘贴设置后,圆圈位于左上角,加号与圆圈底部对齐。

此外,上面发布的代码并不是我得到的最接近的代码,因为我可以使用填充轻松完成,但我更喜欢使用 flexbox。

维沙尔·达诺提亚

只需更改您的样式,替换为这种样式,并将样式添加到您的顶视图

<View style={{flex:1}}>
        <Text>Agends</Text>
        <View style={styles.reminderView}>
          <TouchableOpacity style={styles.reminderTouch}>
            <Text style={styles.reminderBtn}>+</Text>
          </TouchableOpacity>
        </View>
      </View>




reminderView: {
    flex: 1,
    right:0,
    margin:5,
    bottom:0,
    position:'absolute'
  },

  reminderTouch: {
    width: 60,
    height: 60,
    backgroundColor: 'orange',
    borderRadius: 100,
    justifyContent:'center',
    alignItems:'center',
    margin: 20,
  },

  reminderBtn: {
    fontSize: 50,
    margin: 5,
    alignSelf: 'center',
  }

请查看此snack.expo 链接

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

flex在react-native中的ScrollView中不起作用

来自分类Dev

React Native中的Flex框不起作用按钮不会显示

来自分类Dev

订阅在React Native中不起作用?

来自分类Dev

Flex WebView在React Native中

来自分类Dev

React Native中的多列和行Flex Box问题

来自分类Dev

React-Native alignItems:“flex-end”在 <Image> 标签内不起作用

来自分类Dev

React Native,Flex Box 有问题

来自分类Dev

开关盒在React Native中不起作用

来自分类Dev

number.toLocaleString()在react-native中不起作用

来自分类Dev

Axios发布请求在React Native中不起作用

来自分类Dev

posesEnabled:false在React Native中不起作用

来自分类Dev

onPress在React Native Flatlist中不起作用

来自分类Dev

React Native:NavigationOptions中的标题样式不起作用

来自分类Dev

componentDidMount或componentWillMount在React-Native中不起作用?

来自分类Dev

Pressable在React-Native Android中不起作用

来自分类Dev

获取在 React Native ios 中不起作用

来自分类Dev

Tab 中的 react-native-maps 不起作用

来自分类Dev

React Native 中的垂直居中不起作用

来自分类Dev

在 React Native fetch 方法中解析 JSON 不起作用

来自分类Dev

react-native 中的导航不起作用

来自分类Dev

视图样式在 React Native 中不起作用

来自分类Dev

React Native中的Flexbox'flex'属性

来自分类Dev

浮动在flex容器中不起作用

来自分类Dev

显示:flex在Chrome中不起作用

来自分类Dev

Display Flex在IE中不起作用

来自分类Dev

Flex高度在Chrome中不起作用

来自分类Dev

flex 在 Firefox 53 中不起作用

来自分类Dev

React Native Typescript模板不起作用

来自分类Dev

React Native Android Example不起作用

Related 相关文章

热门标签

归档