android - React-Native 中带有实心阴影的文本

标签 android css react-native text shadow

我正在开发一个应用程序并尝试在 React-Native 中实现纯阴影(根据设计要求),如下图所示。

enter image description here

注意:我不能使用图像,因为这是一个多语言应用程序。

我尝试了什么。

我试图在文本背景上添加阴影,但看起来像这样:-

样式代码:

{
    textShadowColor: 'rgba(255, 255, 255, 1)',
    textShadowOffset: { width: 1, height: 1 },
    textShadowRadius: 5,
    fontWeight:'bold',
}

enter image description here

然后我尝试了 borderWidth,它也没有用,它适用于组件边框。

样式代码:

{
    textShadowColor: 'rgba(255, 255, 255, 1)',
    textShadowOffset: { width: 1, height: 1 },
    textShadowRadius: 5,
    fontWeight:'bold', 
    borderWidth:1,
    borderColor:'white'
}

enter image description here

两者都不适合我。没有人比设计更接近。有什么解决办法吗? 或者在React-Native中无法实现。

最佳答案

我发现只有两种方法可以解决这个问题。

  1. 困难 - 将字体转换为 SVG 并仅使用带有 svg 参数的字母或单词或使用 Canvas
  2. 简单 - 将单词换行以查看并添加具有绝对位置的重复项
<View style={{position: 'relative'}}>
  <TextWithShadow style={{position:'relative'}}>Word</TextWithShadow>
  <TextWithShadow style={{position:'absolute'}}>Word</TextWithShadow>
  <TextWithShadow style={{position:'absolute'}}>Word</TextWithShadow>
<View>

Shadow

这种方式有助于获得更浓密的阴影。更多迭代 - 更多密度

关于android - React-Native 中带有实心阴影的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51611619/

相关文章:

html - 制作一个列高度相同的表格

javascript - 平滑滚动 WordPress 上的粘性标题不起作用

ios - 是否可以将在linux中使用react-native开发的ios应用程序运行到真正的iphone

firebase - 从 auth firebase、firestore 和 firebase 函数到 getStream.io 聊天的最佳工作流程

java - 广播接收器未接收到广播

Android Activity 不会填满 WVGA 屏幕

android - flutter 应用程序 : Required to terminate screen while navigating to next screen

android - 从 Android 应用程序调用 Java EE Web 服务

javascript - 有没有办法制作一个动态放置的半透明div "holes"

reactjs - 在 React Navigation 中使用组件作为标题标题