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

Android drawable 資源中的 shape 標籤整理

編輯:關於 Android 開發

drawable 中的 shape

在 Android 開發中,drawable 資源除了可使用圖片,也能以 XML 定義形狀。shape 常用於建立按鈕背景、卡片邊框、分隔線與圓角容器,能減少對額外圖片的依賴。

shape 可描述矩形、橢圓、線段與環形等基本外觀,並可搭配填色、漸層、邊框、內距與尺寸等屬性。開發者可將其放在 drawable 目錄,再透過背景或前景資源引用。

使用 shape 的優點是輕量、可縮放且易於維護;若需要動態切換狀態,也可搭配 selector 或自定義 View 的繪製邏輯。

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