Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android ListView 圓角背景快速實作

編輯:關於 Android 程式設計

若希望 ListView 呈現圓角或類似對話框的外觀,可以利用系統內建的 Drawable 資源作為背景,並將 cacheColorHint 設定為透明,避免捲動時出現不自然的底色。

重點在於 ListView 的 android:background 與 android:cacheColorHint 兩個屬性。例如使用 android:background="@android:drawable/dialog_frame" 以及 android:cacheColorHint="@color/transparent",即可快速得到乾淨的圓角效果。

這種做法很簡單,不需要額外建立複雜的自訂 Drawable,就能讓清單視覺更精緻。若專案需要更深度的樣式控制,也可以再搭配自訂背景圖或 Shape Drawable。

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