1. 程式人生 > >Android xml 寫的控制元件背景

Android xml 寫的控制元件背景

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <!-- 背景顏色 -->
    <solid android:color="@android:color/transparent"/>
    
    <!-- 邊框顏色, 邊框寬度, 虛線的線長, 虛線的間距 -->
    <stroke 
        android:color="#000ff0"
        android:width="1dp"
	android:dashWidth="10dp"
	android:dashGap="5dp"/>

    <!-- 四角的弧度 -->
    <corners android:radius="20dp"/>
    
</shape>

背景顏色裡@android:color/transparent為透明

如果不想讓邊框為虛線的話, 虛線的線長和間距兩句可以刪掉