Android平铺背景图片:使用位图调整图片大小吗?

| 我想在我创建的布局中沿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重复平铺是否有替代方法?还是有一些我尚未检查的解决方法?我已经更改了抗锯齿,抖动,过滤器等所有选项。似乎没有任何改变。 谢谢您的帮助! 编辑:这似乎是使用图形布局工具的错误。在我的手机上看起来还可以。     
已邀请:
        请检查以下链接: 链接1 链接2 希望这些对您有帮助!!!     
        使用“图形布局”工具似乎是一个错误。在我的手机上看起来还可以。     
        您不能使用xml在一个方向上重复位图背景,但是Java代码肯定可以做到这一点。
BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(R.drawable.image);
 bitmap.setTileModeX(TileMode.REPEAT);
所以现在如果您将此\“ bitmap \”设置为任何视图的背景 例如:如果我们有一个TextView \“ text \”,那么              text.setBackgroundDrawable(bitmap)将设置此文本视图的背景              到“位图”。 它会在x方向上重复,但会保留在y方向上的高度 希望这可以帮助。     

要回复问题请先登录注册