<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" > <!-- 定义Button的控件--> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/btn_bg" android:text="圆角按钮" /> </LinearLayout>
btn_bg.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <!-- 定义按钮的背景的颜色 --> <solid android:color="#00CCFF" /> <!-- 设置按钮的每个角的弧形角度 --> <corners android:radius="10dip" /> <!-- 按钮文字与边界的距离 --> <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" /> </shape>