ImageView背景太大了

时间:2014-07-15 23:17:53

标签: android image background imageview

我正在制作一个需要在ImageView上设置背景颜色的android应用程序。图像是带有透明部分的纯白色方块(一种掩模),但我看到背景"溢出"边界,勾勒出轮廓。我该如何解决这个问题?

谢谢!

相关的XML代码如下:

<ImageView
        android:id="@+id/tile1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/hexagon"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:layout_marginLeft="@dimen/hexagon_horizontal_margin"
        android:layout_marginRight="@dimen/hexagon_horizontal_margin"
        android:background="#ffff000b"/>

hexagon_horizontal_margin设置为4dp)

图像为100x100像素,这就是它在模拟器中的外观:

Screenshot

2 个答案:

答案 0 :(得分:1)

问题出在你的六角形上。 Drawable每侧的外部像素都是透明的。因此,当您将颜色设置为背景时。这些像素让背景颜色显示出来。编辑您的drawable以删除透明度并完成。

尝试使用这个drawable:

Try with this one :D

答案 1 :(得分:0)

问题在于您的六角形可绘制。如果仔细观察边缘,您会发现白色叠加层会逐渐消失。 ImageView本身正在运作。

相关问题