日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 写字体投影,android-给字体设置投影

發布時間:2025/3/12 编程问答 11 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 写字体投影,android-给字体设置投影 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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是繼承TextView的,所以Button也可以在代碼中使用setShadowLayer(float radius, float dx, float dy, int color)方法

2,在配置文件中添加文字陰影

android:id="@+id/name"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/person_popularvalue"

android:layout_alignParentLeft="true"

android:layout_marginBottom="5.0dip"

android:layout_marginLeft="10.0dip"

android:shadowColor="@color/black"

android:shadowDx="0"

android:shadowDy="1"

android:shadowRadius="1"

android:textColor="@color/white"

android:textSize="14sp" >

android:shadowColor 陰影的顏色

android:shadowDx 陰影的水平偏移量

android:shadowDy 陰影的垂直偏移量

android:shadowRadius 陰影的范圍

需要注意的地方 :將android:shadowRadius=0 的時候是看不到陰影的

Button的文字陰影效果的添加與上面的一樣。

3,示例:

總結

以上是生活随笔為你收集整理的android 写字体投影,android-给字体设置投影的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。