位图TileX ONLY [英] Bitmap TileX ONLY

查看:121
本文介绍了位图TileX ONLY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的形象在X轴只能重复。

I want my image to repeat only in X axis.

我用这个code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout l = new LinearLayout(this);
    l.setLayoutParams(new LayoutParams(-2, -2));
    BitmapDrawable b = null;
    try {
        b = new BitmapDrawable(getAssets().open("pattern.jpg"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    b.setTileModeX(TileMode.REPEAT);

    l.setBackgroundDrawable(b);

    setContentView(l);
}

当我执行我的应用程序,重复的位图在X轴,但我在显示Y轴的东西串

When i execute my app, bitmap repeat in X axis but i show something string in Y axis

http://img24.imageshack.us/img24/9027/rgxt.png

如果我尝试在Y轴重复,它发生相同的,但在X轴。

If i try to repeat in Y axis, it happens the same but in the X axis.

我怎么能重复我的形象只有在X轴上没有看到论文纵线?

How can i repeat my image only in X axis without seeing theses vertical "lines"?

推荐答案

看来你的位图需要一个 CLAMP TILEMODE Y轴。

It appears that your bitmap takes a CLAMP tilemode in Y.

我想这是默认值。

您应该定义您所需要的垂直方向,因为你的图片太小了你的背景,你要重复一次吗?或STRETCH时呢?

You should define what you need for the vertical direction, since your image is to small for your background, do you want to repeat it ? or strech it ?

如果你不希望任何这一点,但人只需要另一种颜色此图像下方的空间,你应该考虑在图像的底部加入了一个像素的水平线。

if you don't want any of this, but need simply another color for the space under this image, you should consider adding a one pixel horizontal line at the bottom of the image.

然后让 CLAMP TILEMODE这种颜色扩展到整个背景。

then let the CLAMP tilemode extend this color to the entire background.

在此<获得更多的信息href=\"http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html#attr_android%3atileMode\"相对=nofollow>这里

这篇关于位图TileX ONLY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆