Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
您现在的位置: Android教程網 >> Android系統教程 >  >> Android 手機 >> Android 手機知識

Android字體陰影的實作思路與反編譯改包方向

編輯:Android 手機知識

Android 本身支援文字陰影效果,原理和 Photoshop 的投影類似。在 TextView 上實作陰影,效率會比在位圖元件上處理更好,也更容易適配各種螢幕尺寸——畢竟 LayoutManager 縮放 TextView 遠比在 ImageView 裡縮放位圖單純。

先說明一下:以下內容需要具備基本的反編譯與改包經驗,完全沒有基礎的用戶不建議嘗試;本教學僅適用於懂得使用反編譯工具解包、打包的人。

一、陰影效果的四個關鍵參數

1. android:shadowColor:陰影顏色

2. android:shadowDx:水平方向偏移量

3. android:shadowDy:垂直方向偏移量

4. android:shadowRadius:陰影擴散範圍

二、從最簡單的陰影開始

「字體陰影」其實是個約定俗成的說法,因為透過參數的組合,實際能做出與陰影毫不相干的效果。先從最基礎的投影寫起:

<LinearLayout
   xmlns:android="https://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:background="@color/White"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
   <TextView android:textColor="@color/Black"
      android:layout_width="wrap_content"
      android:text="Simple Shadow"
      android:layout_height="wrap_content"
      android:padding="2dp"
      android:shadowColor="@color/TransparentGrey"
      android:shadowDx="3"
      android:shadowDy="3"
      android:shadowRadius="0.01" />
</LinearLayout>

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved