閱讀990 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Android TextView顯示文字過長時添加陰影漸變消失效果

TextView 上顯示的文字超過其最長限製的時候,要如何實現以下效果:

 

values/styles.xml 

<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">#ff00ff00</item> 
    <item name="android:shadowDx">5</item> 
    <item name="android:shadowDy">3</item> 
    <item name="android:shadowRadius">6</item> 
</style> 

<TextView android: 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
        
       android:text="aaaa" 
         android:gravity="center" /> 

android:shadowColor指定文本陰影的顏色,需要與shadowRadius一起使用。 
android:shadowDx設置陰影橫向坐標開始位置。 
android:shadowDy設置陰影縱向坐標開始位置。 
android:shadowRadius設置陰影的半徑。設置為0.1就變成字體的顏色了,一般設置為3.0的效果比較好。

最後更新:2017-04-02 16:47:36

  上一篇:go Android 自定義PopupWindow動畫效果
  下一篇:go Instruments使用小記(2012-11-28更新)