Android shape

shape

理解

    shape就是對view背景進行修改調整的一個屬性文件,可以任意更改view的形狀,顏色等。它作爲一個drawable文件,放在項目的res/drawable目錄下,使用時候,需要放在view的background屬性下。

屬性

  • corners

    定義四個角

屬性 解釋
android:radius=“dimension” 全部的圓角半徑
android:topLeftRadius=“dimension” 左上角的圓角半徑
android:topRightRadius=“dimension” 右上角的圓角半徑
android:bottomLeftRadius=“dimension” 左下角的圓角半徑
android:bottomRightRadius=“dimension” 右下角的圓角半徑
  • solid

    定義內部顏色

android:color="#ffff00" 顏色
  • gradient

     定義漸變色,可以定義兩色漸變和三色漸變,及漸變樣式

屬性 解釋
android:type=[“linear” | “radial” | “sweep”] 共有3中漸變類型,線性漸變(默認)/放射漸變/掃描式漸變
android:angle=“integer” 僅對線性漸變有效, 漸變角度,必須爲45的倍數,0爲從左到右,90爲從上到下
android:centerX=“float” 漸變中心X的相當位置,範圍爲0~1
android:centerY=“float” 漸變中心Y的相當位置,範圍爲0~1
android:startColor=“color” 漸變開始點的顏色
android:centerColor=“color” 漸變中間點的顏色,在開始與結束點之間
android:endColor=“color” 漸變結束點的顏色
android:gradientRadius=“float” 漸變的半徑,只有當漸變類型爲radial時才能使用
android:useLevel=[“true” | “false”] /> 使用LevelListDrawable時就要設置爲true。設爲false時纔有漸變效果
  • stroke

    描邊屬性,可以定義描邊的寬度,顏色,虛實線

屬性 解釋
android:width=“dimension” 描邊的寬度
android:color=“color” 描邊的顏色
以下兩個屬性設置虛線
android:dashWidth=“dimension” 虛線的寬度,值爲0時是實線
android:dashGap=“dimension” 虛線的間隔
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章