设置边框圆角能够在drawable-mdpi目录里定义一个xml: android
<?xml version="1.0" encoding="utf-8"?> ide
<shape xmlns:android="http://schemas.android.com/apk/res/android"> spa
<solid android:color="#000000" /> orm
<corners android:topLeftRadius="10dp" xml
android:topRightRadius="10dp" ip
android:bottomRightRadius="10dp" utf-8
android:bottomLeftRadius="10dp"/> string
</shape> it
解释:solid的表示填充颜色,为了简单,这里用的是黑色。
而corners则是表示圆角,注意的是这里bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。
固然上面的效果也能够像下面同样设置,以下: io
<corners android:radius="5dp" />
若是想引用这个xml,只须要@drawable/corners_bg.xml便可:
android:background="@drawable/corners_bg"
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#FFFFFF">
<RelativeLayout android:id="@+id/login_div"
android:layout_width="fill_parent" android:layout_height="150dip"
android:padding="15dip" android:layout_margin="15dip"
android:background="@drawable/corners_bg">
</RelativeLayout>
</LinearLayout>
运行结果: