Android的 - 文本上的投影? [英] Android - shadow on text?

查看:202
本文介绍了Android的 - 文本上的投影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何添加文本上的投影在机器人?

I am wondering how to add shadow on text in android?

我有被应用在一个位图下面的code,我想被隐藏...

I have the following code which is applied on a bitmap and I wanted to be shadowed...

paint.setColor(Color.BLACK);
paint.setTextSize(55);
paint.setFakeBoldText(false);
paint.setShadowLayer(1, 0, 0, Color.BLACK); //This only shadows my whole view...

感激任何提示!

Thankful for any tips!

推荐答案

您应该能够添加的样式,像这样(摘自来源$ C ​​$下Ringdroid):

You should be able to add the style, like this (taken from source code for Ringdroid):

  <style name="AudioFileInfoOverlayText">
    <item name="android:paddingLeft">4px</item>
    <item name="android:paddingBottom">4px</item>
    <item name="android:textColor">#ffffffff</item>
    <item name="android:textSize">12sp</item>
    <item name="android:shadowColor">#000000</item>
    <item name="android:shadowDx">1</item>
    <item name="android:shadowDy">1</item>
    <item name="android:shadowRadius">1</item>
  </style>

而在你的布局,使用的样式是这样的:

And in your layout, use the style like this:

 <TextView android:id="@+id/info"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       style="@style/AudioFileInfoOverlayText"
       android:gravity="center" />

编辑:来源$ C ​​$ C可以在这里查看: HTTP://$c$c.google .COM / P / ringdroid /

EDIT2: 以编程方式设置这种风格,你会做这样的事情(从<改良href="http://stackoverflow.com/questions/4630440/how-to-change-a-textviews-style-at-runtime/4632208#4632208">this例如,向上述匹配ringdroid的资源)

To set this style programmatically, you'd do something like this (modified from this example to match ringdroid's resources from above)

TextView infoTextView = (TextView) findViewById(R.id.info);
infoTextView.setTextAppearance(getApplicationContext(),  
       R.style.AudioFileInfoOverlayText);

有关签名 setTextAppearance

公共无效setTextAppearance(上下文的背景下,INT渣油)

public void setTextAppearance (Context context, int resid)

自:API级别1
  设置文本颜色,大小,样式,颜色提示,以及   高亮颜色从指定TextAppearance资源。

Since: API Level 1
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

这篇关于Android的 - 文本上的投影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆