繁体   English   中英

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

[英]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"/>

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

将文本颜色设置为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"/>

您可以根据需要增加半径,并根据需要着色

在此处输入图片说明

您也可以尝试使用字体.....

用过的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之类的Web服务来查找任何图片中使用的警察。 我用你的照片找到了最接近的匹配并得到了这个答案:

WhatTheFont答案

警察是Minutia Outline ,您可以在这里找到它

我不确定这是您所追求的解决方案,但是使用此警察将为您提供确切的照片。

如果您不想使用字体,则可以简单地使用一些CSS设置文本样式, 使用webView在Android中使用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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM