我想繪製一個圖像作爲背景的按鈕。 這裏是我的xml:試圖畫一個按鈕
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="13dp"
android:background="@drawable/button_bg"
android:text="Break Record"
android:textColor="#2c4417"
android:textSize="19dp"
android:textStyle="bold" >
</Button>
</LinearLayout>
在圖形佈局來看,它看起來像我預期:
但在模擬器上的按鈕可以讓屏幕的整個寬度:
我已經閱讀過規範不止一次,但不能得到我的錯誤,
如何編寫按鈕xml,使按鈕將l在Eclipse的圖形化佈局中,在模擬器(和所有設備上)?
謝謝。
你對所有屏幕都有單獨的背景嗎? – 2012-04-04 06:53:35
如果你打算詢問我是否有單獨的背景圖像的所有決議 - 答案是否定的,我目前有1背景圖像PNG。如果您打算詢問相同的背景是否適用於我的應用中的所有屏幕 - 答案是肯定的。 – 2012-04-04 07:05:41
我指的是按鈕的背景,即@ drawable/button_bg。你應該對每個密度都有所不同。 [看看這個開發指南](http://developer.android.com/guide/practices/screens_support.html) – 2012-04-04 07:09:41