android控制元件或佈局設定圓角
<solid android:color="#ffcccccc"/>
<corners android:topLeftRadius="10dp"
android:topRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"/>
</shape> 在ui的xml檔案中給控制元件的background屬性設定,如android:background="@drawable/view_shape",這樣即可以看到一個弧形的邊框出現。 如圖: 如果是自定義組和控制元件或者佈局設定圓角,則需要將android:background="@drawable/view_shape
/** * 在程式碼中設定圓角 * @param path */ public void setListItemBorder(int path){ list_item = (RelativeLayout) findViewById(R.id.list_layout); list_item.setBackgroundResource(path); }然後呼叫這個方法,傳入引數即可獲取到自己定義的xml檔案中的屬性了。