首页 > 解决方案 > 在我的 react native 项目中使用原生基础的 Button 组件,它在 android 文本中产生问题

问题描述

IOS:

在此处输入图像描述

安卓: 在此处输入图像描述

在 IOS 中它工作正常,但 android 有问题根据上图,我将组件 ButtonWithText.js 的代码如下:

import React from 'react';
import {Text, View} from 'react-native';
import {Button} from 'native-base';

const ButtonWithText = props => {
  const content = (
    <Button transparent style={props.btnStyle} onPress={props.onButtonPress}>
      <Text style={props.textStyle}>{props.title}</Text>
    </Button>
  );
  return <View>{content}</View>;
};
export default ButtonWithText;

目前,从下面给出的父组件传递道具:

<ButtonWithText
 title={'Want To Check Button Text'}
 btnStyle={styles.medicationButton}
 textStyle={styles.medicationButtonText}
 onButtonPress={() => goMedicationRefill(this.props.componentId)}
/>

上面给出的样式如下:

medicationButton: {
    height: 37,
    width: '100%',
    backgroundColor: '#41FD9A',
    borderRadius: 18,
    justifyContent: 'center',
  },
  medicationButtonText: {
    color: '#fff',
    fontWeight: '700',
    fontSize: 16,
  }, 

目前,我使用的是原生版本:2.13.7 和 react-native 版本:0.60.5

请帮我解决这个问题。

标签: androidreact-nativenative-base

解决方案


推荐阅读