我已創建形狀文件按您的要求:
1)以下是您的可繪製命名爲:btn_vk_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FABC38"></solid>
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item>
<item>
<bitmap
android:gravity="left|center_horizontal"
android:src="@drawable/vk_login"></bitmap>
</item>
<item>
<shape>
<corners android:radius="10dip" />
<stroke
android:width="2px"
android:color="@android:color/white" />
</shape>
</item>
</layer-list>
2)在你的佈局佈局文件,你可以這樣定義按鈕:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="100dp"
android:background="@drawable/btn_vk_drawable"
android:text="VK"
android:ems="12"
android:textAlignment="center" />
使用9補丁:btn_vk_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FABC38"></solid>
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item>
<item>
<!--<bitmap-->
<!--android:gravity="left|center_horizontal"-->
<!--android:src="@drawable/t"></bitmap>-->
<nine-patch
android:dither="true"
android:src="@drawable/common_signin_btn_text_normal_dark.9" />
</item>
</layer-list>
http://stackoverflow.com/questions/18527467/mask-imageview-with-round-corner-background –