<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ***** **shape自定義樣式** [TOC=6] # shape 用代碼生成圖片,而且圖片能隨意的更改,既方便又節省空間,下面就介紹用shape生成自定義圖形的方法 步驟: 1. 在res/drawable下新建一個xml文件; 2. 在代碼中引用這個xml文件,引用方式和圖片一樣。 定義shape圖形的語法如下: ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle" | "oval" | "line" | "ring"] //共有4種類型,矩形(默認)/橢圓形/直線形/環形 // 以下4個屬性只有當類型為環形時才有效 android:innerRadius="dimension" //內環半徑 android:innerRadiusRatio="float" //內環半徑相對于環的寬度的比例,比如環的寬度為50,比例為2.5,那么內環半徑為20 android:thickness="dimension" //環的厚度 android:thicknessRatio="float" //環的厚度相對于環的寬度的比例 android:useLevel="boolean"> //如果當做是LevelListDrawable使用時值為true,否則為false. <corners //定義圓角 android:radius="dimension" //全部的圓角半徑 android:topLeftRadius="dimension" //左上角的圓角半徑 android:topRightRadius="dimension" //右上角的圓角半徑 android:bottomLeftRadius="dimension" //左下角的圓角半徑 android:bottomRightRadius="dimension" /> //右下角的圓角半徑 <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時才有漸變效果 <padding //內部邊距 android:left="dimension" android:top="dimension" android:right="dimension" android:bottom="dimension" /> <size //自定義的圖形大小 android:width="dimension" android:height="dimension" /> <solid //內部填充顏色 android:color="color" /> <stroke //描邊 android:width="dimension" //描邊的寬度 android:color="color" //描邊的顏色 // 以下兩個屬性設置虛線 android:dashWidth="dimension" //虛線的寬度,值為0時是實線 android:dashGap="dimension" /> //虛線的間隔 </shape> ~~~ 下面是幾個示例: 1. 圓角矩形,掃描式漸變 ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:useLevel="false" > <corners android:topLeftRadius="10dp" android:topRightRadius="10dp" android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" /> <gradient android:type="sweep" android:endColor="@android:color/holo_blue_bright" android:startColor="@android:color/holo_green_dark" android:centerColor="@android:color/holo_blue_dark" android:useLevel="false" /> <size android:width="60dp" android:height="60dp" /> </shape> ~~~ 結果: ![](https://box.kancloud.cn/17b70d4a6a5f378df02bd294d055f4e9_285x323.png) 2. 圓形,線性漸變 ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" android:useLevel="false" > <gradient android:type="linear" android:angle="45" android:startColor="@android:color/holo_green_dark" android:centerColor="@android:color/holo_blue_dark" android:endColor="@android:color/holo_red_dark" android:useLevel="false" /> <size android:width="60dp" android:height="60dp" /> <stroke android:width="1dp" android:color="@android:color/white" /> </shape> ~~~ 結果: ![](https://box.kancloud.cn/1652d0e8c9b509b568a4584fcbadaef0_286x328.png) 3. 虛線 ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <size android:width="60dp" android:height="60dp" /> <stroke android:width="2dp" android:color="@android:color/holo_purple" android:dashWidth="10dp" android:dashGap="5dp" /> </shape> ~~~ 結果: ![](https://box.kancloud.cn/d050da5e642f6daa2ebe3b797de2989e_272x53.png) 4. 環形,放射型漸變 ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:useLevel="false" android:innerRadius="40dp" android:thickness="3dp"> <gradient android:type="radial" android:gradientRadius="150" android:centerY="0.1" android:centerX="0.2" android:startColor="@android:color/holo_red_dark" android:centerColor="@android:color/holo_green_dark" android:endColor="@android:color/white" /> <size android:width="90dp" android:height="90dp" /> </shape> ~~~ 結果: ![](https://box.kancloud.cn/e15cd018569f07fe930d42b1fa575d3e_127x123.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看