Java 具有两种颜色的自定义文本样式

Java 具有两种颜色的自定义文本样式,java,android,android-studio,colors,background-color,Java,Android,Android Studio,Colors,Background Color,我想知道是否有可能对文本设置如下样式: 注意:我使用的是shadow,但对我来说似乎没有什么用处。我想得到一个双色文本,如上图所示 这是我的代码: <com.example.fabulous.comic.CustomTXT android:textColor="@color/white" android:shadowColor="@color/blacke" android:layout_margin="2dp" android:id="@+id/txt"

我想知道是否有可能对文本设置如下样式:

注意:我使用的是
shadow
,但对我来说似乎没有什么用处。我想得到一个双色文本,如上图所示

这是我的代码:

<com.example.fabulous.comic.CustomTXT
    android:textColor="@color/white"
    android:shadowColor="@color/blacke"
    android:layout_margin="2dp"
    android:id="@+id/txt"
    android:text="hellow"
    android:layout_width="match_parent"/>
    android:layout_height="wrap_content"/>

android:layout\u height=“wrap\u content”/>

为什么不选择带有自定义颜色的自定义字体?
这可能有助于您自定义字体。

是的,您可以创建这样的文本。请参见我的详细答案


将文本颜色设置为白色,将轮廓颜色设置为黑色。

试试这个

 <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textColor="@color/white"
android:textSize="20sp"
android:shadowColor="@color/black" 
android:shadowRadius="2"/>

在TextView中使用阴影可以获得轮廓效果:

android:shadowColor="#000000"
android:shadowDx="1.5"
android:shadowDy="1.3"
android:shadowRadius="1.6"
android:text="CCC"
android:textAllCaps="true"
android:textColor="@android:color/white"
您还可以使用web服务查找任何图片中使用的警察。我用你的照片找到了最接近的匹配项,得到了以下答案:

警方正在调查细节,你可以

我不确定这是你想要的解决方案,但是使用这个警察会让你完全了解你的照片

如果您不喜欢使用字体,您可以简单地使用一些CSS来设置文本样式,在Android中如下所示:

.strokee
{
颜色:白色;
文本阴影:
-1px-1px 0#000,
1px-1px 0#000,
-1px 1px 0#000,
1×1×0#000;
字体大小:250%;
}

这就是你要找的吗?

将自定义字体应用于文本快速修复:使用类似的自定义字体。@请检查我的答案。如果可以使用字体,为什么还要创建另一个视图?是的,可以使用字体,但不能控制字体的属性,如轮廓宽度,颜色和里面的颜色一样。@erfan通过打勾和在两个帖子中投票来表达更多的爱。我的荣幸。如果我的回答有帮助,请投票表决。非常感谢。
android:shadowColor="#000000"
android:shadowDx="1.5"
android:shadowDy="1.3"
android:shadowRadius="1.6"
android:text="CCC"
android:textAllCaps="true"
android:textColor="@android:color/white"