700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android 文字添加阴影 android中给TextView或许Button的文字添加阴影效果

android 文字添加阴影 android中给TextView或许Button的文字添加阴影效果

时间:2023-05-28 17:31:51

相关推荐

android 文字添加阴影 android中给TextView或许Button的文字添加阴影效果

android中给TextView或者Button的文字添加阴影效果

1在代码中添加文字阴影

TextView 有一个方法

/**

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

* distance from its normal position.

*

* @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;

invalidate();

}

mTextView.setShadowLayer(10F, 11F,5F, Color.YELLOW); 第一个参数为模糊度,越大越模糊。 第二个参数是阴影离开文字的x横向距离。 第三个参数是阴影离开文字的Y横向距离。 第四个参数是阴影颜色。(如果模糊度为0是看不到阴影效果的)

Button是继承TextVie

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。