我正在努力使button'corners圓,以及設置背景圖像。雖然我能夠實現具有圓角的按鈕,但不能將圖像設置爲背景。當我嘗試android:drawableTop:@drawable/filename
時,該按鈕會再次轉換爲其默認形狀,並且文字會在圖像下方顯示,但我希望將圖像作爲背景,那麼如何將這兩種東西(圓角和背景圖像)應用於按鈕?設置圓角和圖像到一個按鈕
我已經創建了一個名爲button_shape
的xml文件,它的代碼是:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<solid android:color="#ffffff"
/>
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
<stroke android:width="3dp" android:color="#000000" />
</shape>
,並在那裏我已經把該按鈕的主要xml文件的代碼是:
<Button
android:id="@+id/button1"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginTop="179dp"
android:background="@drawable/button_shape"
android:text="Button"
android:textColor="#000000"
/>
請幫助我。
嗨,我有你指定什麼時候清潔工程:) – jenuine 2012-08-10 10:52:41