android中shape布局詳解

來源:互聯網
上載者:User

今天在看SDK文檔的時候發現了一個很是奇怪的布局檔案,裡邊是有關shape布局的xml檔案,霎時間不知道這是什麼東東,因此開始了狂搜SDK的開發指南,又從網上找了一大圈,終於是把shape的布局方式KO掉了,google真是強大啊,下面是sdk中的shape布局代碼,我們慢慢KO之

<?xml version="1.0" encoding="utf-8"?><br /><shape xmlns:android="http://schemas.android.com/apk/res/android"><br /> <solid android:color="#00000000"/><br /> <stroke android:width="1dp" color="#ff000000"/><br /> <padding android:left="1dp" android:top="1dp"<br /> android:right="1dp" android:bottom="1dp" /><br /></shape>

solid android:color=“”  //使用這種顏色全部實心填充

stroke  描邊

android:width=“1dp” color=“#ff000000” 邊的顏色是#ff000000,寬度為1dp

padding  間隔 距離上下左右邊框的距離為1dp

在開發的過程中你還會用到

gradient   此屬性控制布局的漸層顏色

如<gradient android:startColor="#ff0000"

                    android:endColor="#ffffff"            設定漸層顏色,從#ff0000漸層到#ffffff

                    android:angle="90"                      設定漸層角度必須為45度得整數倍

                    android:type="linear"                   將漸層模式設定成線性模式

>

corners 屬性設定邊角角度

<corners

        android:topRightRadius="20dp"    右上方
        android:bottomLeftRadius="20dp"    右下角
        android:topLeftRadius="1dp"    左上方
        android:bottomRightRadius="0dp"    左下角

>

 


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.