android 阴影背景显示文字_Android TextView设置阴影效果

前言

UE需要在android的文字上加上阴影效果,之前不知道原来TextView有这样一个属性可以设置文字阴影~记录一下

代码实现

/**

* Gives the text a shadow of the specified blur radius and color, the specified

* distance from its drawn position.

*

* The text shadow produced does not interact with the properties on view

* that are responsible for real time shadows,

* {@link View#getElevation() elevation} and

* {@link View#getTranslationZ() translationZ}.

*

* @see Paint#setShadowLayer(float, float, float, int)

*

* @attr ref android.R.styleable#TextView_shadowColor

* @attr ref android.R.styleable#TextView_shadowDx

* @attr ref android.R.styleable#TextView_shadowDy

* @attr ref android.R.styleable#TextView_shadowRadius

*/

public void setShadowLayer(float radius, float dx, float dy, int color) {

mTextPaint.setShadowLayer(radius, dx, dy, color);

mShadowRadius = radius;

mShadowDx = dx;

mShadowDy = dy;

mShadowColor = color;

// Will change text clip region

if (mEditor != null) {

mEditor.invalidateTextDisplayList();

mEditor.invalidateHandlesAndActionMode();

}

invalidate();

}

备注: shadowRadius是阴影模糊半径

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值