English 中文(简体)
安德森-波图
原标题:Android - Background Image Animation in Loop

I m trying to animate an image (used as background image but it doesn t really matter) in such a way that it will move from left to right but in a cyclic way. For example, if the image size is exactly as the view size, once the most right column of pixels exceeded the right edge, it will appear on the most left side of the view.

我对采取这种做法的几种方法进行了思考,但所有这些方法对我来说都过于复杂,我确信,这样做还有更多的“核心”方法。

Thanks, Lior.

最佳回答

您能否使用<代码>canvas.drawBitmap(资料来源:Rectangle,outputRectangle,null),将一部分从光线图背景中删除? 这是一种类似的方法,用于绘制一张比图,但是,在给背景地带的边缘点打上前,你会给来源的Rectangle的左侧和正确价值增加一el。

问题回答

如果<代码>Bitmap和ImageView在纸浆中是完全相同的大小,那么你可以人工将纸浆放在你想要的周围。

int pixels[];
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
shiftPixels(pixels, width, height);
bitmap.setPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.setWidth());

在<代码>中,Pixels简单地提供了原始轨道图的复印件,但在复制该图纸时,则适用直线转换成像。 与此类似(未经测试的假体编码);

void shiftPixels(int inPixels[], int bitmapHeight, int nPixHorizShift)
{

    int shift = bitmapHeight * nPixHorizShift;
    int outPixels[inPixels.size()];

    for i = 1:pixels.size()
       outPixels[(i + shift) % outPixels.size()] = inPixels[i];

    inPixels = outPixels;
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签