Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 距离相等的按钮看起来模糊_Android_Layout_Imagebutton - Fatal编程技术网

Android 距离相等的按钮看起来模糊

Android 距离相等的按钮看起来模糊,android,layout,imagebutton,Android,Layout,Imagebutton,我在一个线性布局中有4个图像按钮,它们之间的距离相等。现在我使用一个背景来显示所有4个ImageButton,资源的大小是36x36 ImageButton出现拉伸和模糊。我做错了什么 <LinearLayout android:id="@+id/layout_buttons" android:layout_width="fill_parent" android:layout_height="wrap_content" an

我在一个线性布局中有4个图像按钮,它们之间的距离相等。现在我使用一个背景来显示所有4个ImageButton,资源的大小是36x36

ImageButton出现拉伸和模糊。我做错了什么

<LinearLayout
        android:id="@+id/layout_buttons"

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_weight="1"
        android:gravity="center"
        android:background="@drawable/bg_tabbar_tile"
        >

        <ImageButton
            android:id="@+id/play"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:background="@drawable/play"
            android:layout_weight="1" 
            />
        <ImageButton
            android:id="@+id/play1"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:background="@drawable/play"
            android:layout_weight="1"
            />

        <ImageButton
            android:id="@+id/play2"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:background="@drawable/play"
            android:layout_weight="1"
            />

        <ImageButton
            android:id="@+id/play3"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:background="@drawable/play"
            android:layout_weight="1"
            />
        </LinearLayout>


提前感谢

默认情况下,背景绘图将拉伸到包含视图的大小。可以通过使用BitmapDrawable来避免这种情况。将其放入
res/drawable
中的新XML文件中:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/play"
      android:gravity="center" />


然后在图像按钮中使用这个新的drawable,而不是
@drawable/play

我给xml文件取什么名字有关系吗?完美的答案…以下是我所做的…在drawable folder created button.xml中,它有@Abid-你可以给它取任何名字。很抱歉,我遗漏了xmlns属性。我将编辑我的答案,以包括这一点,以防其他人试图模仿这一点。