react-native - 溢出 : 'hidden' && borderRadius not working properly in React Native Android

标签 react-native react-native-android

borderRadius 在 iOS 中按预期工作,但在 Android 中不按预期工作。我试图包装 Image在一个 View 中,给了 borderRadiusoverFlow: 'hidden'

  <View style={styles.userImageContainer}>
    <Image source={require('../../assets/images/user1.png')}
    style={styles.userImage}
    />
  </View>

样式表
const imageSize = 40;

  userImageContainer: {
    height: imageSize,
    width: imageSize,
    borderWidth: 1,
    alignItems: 'center',
    justifyContent: 'center',
    borderRadius: imageSize/2,
    overflow: 'hidden'
  },
  userImage: {
    height: imageSize,
    width: imageSize,
    borderRadius: imageSize/2,
    padding: 5,
    resizeMode: 'contain'
  },

最终结果 Image

我正在使用 RN 0.42.2

最佳答案

更新

申请borderRadiusresizeMode作为 Prop 而不是作为样式属性将修复Android中的borderRadius问题

<Image
  source={{uri: 'path'}}
  style={styles.image}
  resizeMode="cover"
  borderRadius={value}
/>

对于那些面临这个问题的人来说,这是 react-native android 的一个已知问题。到目前为止,还没有修复它。

https://facebook.github.io/react-native/releases/0.26/docs/known-issues.html#the-overflow-style-property-defaults-to-hidden-and-cannot-be-changed-on-android

关于react-native - 溢出 : 'hidden' && borderRadius not working properly in React Native Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42787032/

相关文章:

android - 加密epub文件

reactjs - React JS Web 代码可以用于使用 React Native 构建移动应用程序吗?

reactjs - 使用 React-Apollo 设置 React-Storybooks

javascript - 使用 React Native 和 Laravel 后端对 Pusher 进行身份验证

react-native - com.android.builder.testing.api.DeviceException : com. android.ddmlib.InstallException: INSTALL_FAILED_DEXOPT

android - react-native 中的导入 com.android.build.OutputFile 错误

android - 深度链接不会在 Android 中自动打开

android - 任务 ':react-native-get-sms-android:verifyReleaseResources' 的 React Native 构建错误执行失败

react-native - FlatList 中的 TextInput 在离屏时失去焦点

react-native - 图像背景不会出现