我想在我创建的布局中在 x 方向上有一个平铺背景。我已经按照网上找到的一些很好的说明正确平铺,但是源图像现在垂直拉伸了很多。我认为这与位图文件类型的性质有关。
示例图片:
第一个图像是平铺前的背景图像。第二张图片是平铺后的。如您所见,图像被垂直拉伸了一点,并且由于调整大小而显得有点模糊。
我尝试将图像放在 drawable-hdpi 和 drawable 文件夹中。我尝试将 XML 文件放在两个文件夹中。这些似乎都不重要。
这是生成这两个图像的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/bg" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/bg_repeat" />
</LinearLayout>
“@drawable/bg”是实际图像本身,bg.png。“@drawable/bg_repeat”是以下位图 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/cdetail_bg_unclaimed_details"
android:antialias="false"
android:dither="false"
android:filter="false"
android:gravity="center|center_vertical"
android:tileMode="repeat" />
对于 x-repeat 平铺,是否有替代方法?还是有一些我还没有检查过的解决方法?我已经更改了抗锯齿、抖动、过滤器等的所有选项。似乎没有任何改变。
谢谢您的帮助!
编辑:这似乎是使用图形布局工具的错误。在我的手机上看起来还可以。