7

是否可以TextView像这样在 Android 中的 a 的文本上放置一个内部阴影:

http://i.stack.imgur.com/88Mxd.png

谢谢 !

4

3 回答 3

7

MagicTextView会做内阴影。

在此处输入图像描述

    <com.qwerjk.better_text.MagicTextView
        xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text"
        android:textSize="42dp"
        android:textColor="#FFffff00"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:padding="10dp"
        qwerjk:innerShadowDy="3"
        qwerjk:innerShadowColor="#FF000000"
        qwerjk:innerShadowRadius="5"
        android:text="InnerShadow" />

注意:我做了这个,为了未来的旅行者,我发布的内容比 OP 更多。这是边缘垃圾邮件,但在主题上,也许可以接受?

于 2012-04-24T08:02:26.063 回答
2

对于阴影效果:

 <TextView
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="5sp"
    android:paddingTop="15sp"
    android:paddingBottom="15sp"
    android:typeface="normal"
    android:text="I'm normal (bold) font but I have a shadow"
    android:textSize="16sp"
    android:textStyle="bold"
    android:shadowColor ="#0f0f0f"
    android:shadowRadius="1.6"
    android:shadowDx="1.5"
    android:shadowDy="1.3"
    android:textColor="#000000"
    android:background="#ffffff"
    />

或者,您可以使用自己的字体,将它们放在 res/assets 文件夹中:

TextView txt = (TextView) findViewById(R.id.custom_font);   
Typeface font = Typeface.createFromAsset(getAssets(), "my_font.ttf");  
txt.setTypeface(font);

或查看以下链接了解详细信息:

http://www.barebonescoder.com/2010/05/android-development-using-custom-fonts/

http://www.giantflyingsaucer.com/blog/?p=1421

于 2011-11-01T11:38:08.663 回答
1

这与我几个月前提出的一个问题重复:有没有办法在 Android 上的 TextView 中添加内阴影?

目前没有合适的方法来做到这一点。但是,如果您尝试使用文本颜色的 alpha 和投影,您最终可能会得到接近内部阴影的东西。

于 2011-11-01T11:40:05.207 回答