0

我得到了漂亮的 .png 图像32x32px,当我在我的 android 应用程序中将它们设置为如下按钮时:

button.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.graph));

他们都丑陋而模糊

但是,我知道为什么我将它们添加到所有可绘制文件夹中,但它不会改变任何东西!

有任何想法吗 ?

这是屏幕截图(尽管它看起来并不像实际上那样模糊......): 在此处输入图像描述

4

1 回答 1

0

尝试将您的按钮动态设置为 Wrap_Content :

Button pf = new Button(context);
pf.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

否则,最好在 XML 文件中声明此参数:

 <Button
                android:id="@+id/imageReco"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
              />

享受

于 2013-06-24T08:59:36.237 回答