我想绘制一个图像作为背景的按钮。 这里是我的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