2

我正在尝试将图像从 109x105 缩小到 48x48 以制作按钮背景。我已经在 Photoshop 中进行了缩放,图像是矢量。

但是,当我在手机上运行它时,较小的图像会变得模糊。大图像是完美的,我可以毫无问题地将其加载到手机上,因此质量损失。我必须提到,图像中也有一些文字模糊非常明显。

我尝试使用 9 补丁可绘制,使整个图像可拉伸。我似乎无法在网上找到任何准确解决此问题的答案,因此任何输入都会很有用。

我的问题是,如何在不损失质量的情况下缩小 PNG 图像?这是我在将图像复制到我的可绘制文件夹之前可以做的事情,还是我可以让android自动做的事情。

编辑:问题在代码“@drawable/map”、“@drawable/block_small”和“@drawable/share”末尾附近的 3 个按钮中很明显

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/expandable_deal_back_white"
    android:orientation="horizontal"
    android:padding="8dp" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="23dp"
        android:contentDescription="@string/logo_content_description"
        android:maxHeight="100dp"
        android:maxWidth="100dp"
        android:minHeight="100dp"
        android:minWidth="100dp"
        android:scaleType="fitXY"
        android:src="@drawable/food_selector" />

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="23dp"
            android:background="@drawable/button_selector_new"
            android:padding="8dp"
            android:text="@string/tandc"
            android:textColor="@drawable/button_text_selector_new" />

        <RelativeLayout
            android:id="@+id/RelativeLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp" >

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginLeft="4dp"
                android:layout_marginRight="4dp"
                android:background="@drawable/map"
                android:text="@string/empty" />

            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_toRightOf="@+id/button2"
                android:background="@drawable/block_small"
                android:text="@string/empty" />

            <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_toLeftOf="@+id/button2"
                android:background="@drawable/share"
                android:text="@string/empty" />

        </RelativeLayout>

    </LinearLayout>

</LinearLayout>
4

1 回答 1

0

如何在不损失质量的情况下缩小 PNG 图像?

你没有。根据定义,较小的(按像素计数)图像具有较少的数据。

也就是说,您需要检查几件事以确保模糊是由于图像质量下降而不是其他因素造成的。小图像在您的计算机上看起来不错吗?您是否确定将图像放在正确的drawable文件夹中?

于 2012-09-18T17:18:36.203 回答