Android布局實(shí)現(xiàn)圓角邊框

首先,在res下面新建一個(gè)文件夾drawable,在drawable下面新建三個(gè)xml文件:shape_corner_down.xml、shape_corner_up.xml和shape_corner.xml,分別是下面兩個(gè)角是圓角邊框,上面兩個(gè)角是圓角邊框,四個(gè)角全部是圓角邊框。

shape_corner_down.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#0099CC" />
    <corners android:bottomRightRadius="20dp" 
        android:bottomLeftRadius="20dp"/>
    <stroke android:width="1dp" android:color="#000000"/>
</shape>

shape_corner_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#CCCC99" />   
    <corners android:topLeftRadius="20dp" 
        android:topRightRadius="20dp"  />
    <stroke android:width="1dp" android:color="#000000" />
</shape>

shape_corner.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#99CCFF" />   
    <corners android:topLeftRadius="20dp"
        android:topRightRadius="20dp" 
        android:bottomRightRadius="20dp" 
        android:bottomLeftRadius="20dp"/>
    <stroke android:width="1dp" android:color="#000000" />
</shape>

<solid android:color>設(shè)置了背景顏色。android:topLeftRadius、android:topRightRadius、android:bottomLeftRadius、android:bottomRightRadius分別是左上角、右上角、左下角、右下角的半徑值,設(shè)置了半徑值,相應(yīng)的角就是圓角,半徑值越大,圓角就越大。<stroke>設(shè)置邊界屬性,如邊界的寬度、顏色等。

在activity_main.xml上面放置三個(gè)LinearLayout,分別設(shè)置android:background屬性為shape_corner_up.xml、shape_corner_down.xml和shape_corner.xml

原文:http://www.cnblogs.com/mstk/p/3539587.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,188評(píng)論 25 708
  • 先說(shuō)一下這篇文章里面的內(nèi)容:TCP 客戶(hù)端, 自定義對(duì)話框, 自定義按鈕, ProgressBar豎直顯示, 重力...
    楊奉武閱讀 3,952評(píng)論 0 3
  • 從能識(shí)得幾百個(gè)漢字,便愛(ài)上了讀書(shū),不管新舊,不分種類(lèi),見(jiàn)字便讀。各種連環(huán)畫(huà)、《故事會(huì)》、《山海經(jīng)》,只要家里能見(jiàn)得...
    容之閱讀 267評(píng)論 0 0
  • 幾個(gè)月前《最好的我們》熱映的時(shí)候,我一個(gè)人坐在床上默默等著它的更新,深夜看完,關(guān)上手機(jī)時(shí),心里總會(huì)泛起些許說(shuō)...
    是一一呀閱讀 5,159評(píng)論 0 3
  • 做一個(gè)真實(shí)的自己在這個(gè)時(shí)代很難嗎? 朋友今天對(duì)我講她自己,外表看起來(lái)光鮮亮麗,內(nèi)在全爛了。當(dāng)時(shí)的我呵呵一笑,沒(méi)說(shuō)什...
    解憂小店主閱讀 431評(píng)論 0 0

友情鏈接更多精彩內(nèi)容