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

custom text style with two color

我想知道可以像这样设置文本样式:

注意:我正在使用 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"/>

你为什么不选择自定义颜色的自定义字体? 这 link 可能会帮助您自定义字体。

是的,您可以创建这样的文本,请在此处查看我的 详细答案。

将文本颜色设置为 white,将轮廓颜色设置为 black.

试试这个

 <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"/>

you increase the radius as you want and color as you wish

You Can Also Trying using the Font.....

使用 Montserrat.ttp 下载 google 并且您还使用了更多字体..如您所愿

    String fontPath = "fonts/mont.ttf";
    Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
    btn_reload.setTypeface(tf);

在 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"

您还可以使用 WhatTheFont 之类的网络服务来查找任何图片中使用的警察。我用你的照片找到了最接近的匹配并得到了这个答案:

警察是细节大纲你可以find it here.

我不确定这是否是您想要的解决方案,但使用此警察将使您得到图片中的内容。

如果您不想使用字体,您可以简单地使用一些 CSS 来设置文本样式,Android 中的 webView to use html/css 如下所示:

.strokeme
{
    color: white;
    text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
    font-size: 250%;
}
<div class="strokeme">
    Is this what you were looking for?
</div>