【问题标题】:Border Extends out of outline边框超出轮廓
【发布时间】:2020-12-14 04:38:09
【问题描述】:

我有一个简单的文本框,我已经给出了一个大纲。但是,如果您仔细观察,您会发现边框和边框轮廓不匹配。 View 的白色也延伸到边框轮廓之外。我该如何解决这个问题?

export const AddressTextBox: React.FunctionComponent<AddressTextBoxProps> = ({
  placeName,
}) => {
  return (
    <View style={styles.textBox}>
      <Text style={styles.text}>{placeName}</Text>
    </View>
  );
};

export const styles = StyleSheet.create({
  textBox: {
    backgroundColor: 'white',
    height: moderateScale(50),
    width: '70%',
    marginTop: moderateScale(40),
    alignSelf: 'center',
    borderRadius: moderateScale(20),
    borderColor: '#383838',
    borderWidth: 0.3,
    alignItems: 'center',
    flexDirection: 'row',
  },
  text: {
    fontSize: moderateScale(13),
    flex: 1,
    marginHorizontal: 10,
    textAlign: 'center',
  },
});

编辑:

iOS模拟器中不存在该问题,但Android手机中确实存在。

【问题讨论】:

  • marginHorizo​​ntal 内部文字我认为
  • 删除或评论marginHorizo​​ntal以检查是否有问题
  • 不,这没有帮助@anthonywillismuñoz

标签: javascript css reactjs typescript react-native


【解决方案1】:

我尝试使用这个并且不使用中等比例,它工作正常

<View style={{ flex: 1, backgroundColor: 'pink' }}>
        <View
          style={{
            backgroundColor: 'white',
            height: 50,
            width: '70%',
            marginTop: 40,
            alignSelf: 'center',
            borderRadius: 20,
            borderBottomColor: 'red',
            borderTopColor: 'red',
            borderRightColor: 'red',
            borderLeftColor: 'red',
            borderWidth: 0.3,
            alignItems: 'center',
            flexDirection: 'row'
          }}>
          <Text
            style={{
              fontSize: 13,
              flex: 1,
              marginHorizontal: 10,
              textAlign: 'center'
            }}>
            {'vergaminol'}
          </Text>
        </View>
      </View>

【讨论】:

  • 就像我的代码一样,这适用于零食博览会和 iOS,但不适用于 Android
  • 增加borderWidth 有帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-06
  • 2020-06-17
  • 2013-10-25
  • 1970-01-01
  • 2010-11-12
  • 2019-08-10
  • 1970-01-01
相关资源
最近更新 更多