我正在尝试制作我的第一张动态壁纸。当我在自己的手机(Xperia Arc)上测试我的应用程序时,一切都很好。但是在G2 mini,Galaxy note 10 n8000和Galaxy note 3上运行应用程序后,我发现没有任何效果。
在G2 mini上,背景甚至没有加载,但在这两个音符中,OnOffsetChanged
监听器都不能正常工作。
这是我项目的绘图部分和偏移侦听器,如果需要任何其他方法,请告诉我添加。
private void drawItems(Canvas c) {
c.save();
// item 12
c.drawBitmap(item12Bitmap,item12Left,item12Top,null);
// item 0
c.drawBitmap(item0Bitmap,item0Left,item0Top,null);
// item 1
item1Left = nextLeftGenerator(item1Left,item1NextLeft);
c.drawBitmap(item1Bitmap,item1Left,item1Top,null);
// item 2
item2Left = nextLeftGenerator(item2Left,item2NextLeft);
c.drawBitmap(item2Bitmap,item2Left,item2Top,null);
// item 3
item3Left = nextLeftGenerator(item3Left,item3NextLeft);
c.drawBitmap(item3Bitmap,item3Left,item3Top,null);
// item 4
item4Left = nextLeftGenerator(item4Left,item4NextLeft);
c.drawBitmap(item4Bitmap,item4Left,item4Top,null);
// item 5
item5Left = nextLeftGenerator(item5Left,item5NextLeft);
c.drawBitmap(item5Bitmap,item5Left,item5Top,null);
// item 6
item6Left = nextLeftGenerator(item6Left,item6NextLeft);
c.drawBitmap(item6Bitmap,item6Left,item6Top,null);
// item 7
item7Left = nextLeftGenerator(item7Left,item7NextLeft);
c.drawBitmap(item7Bitmap,item7Left,item7Top,null);
// item 8
item8Left = nextLeftGenerator(item8Left,item8NextLeft);
c.drawBitmap(item8Bitmap,item8Left,item8Top,null);
// item 9
item9Left = nextLeftGenerator(item9Left,item9NextLeft);
c.drawBitmap(item9Bitmap,item9Left,item9Top,null);
// item 10
item10Left = nextLeftGenerator(item10Left,item10NextLeft);
c.drawBitmap(item10Bitmap,item10Left,item10Top,null);
// item 11
item11Left = nextLeftGenerator(item11Left,item11NextLeft);
c.drawBitmap(item11Bitmap,item11Left,item11Top,null);
c.restore();
}
和偏移侦听器:
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xStep,
float yStep, int xPixels, int yPixels) {
Float diffrence;
if (firstOffset == null){
firstOffset = xOffset;
diffrence = 0.0f;
}
else {
diffrence = firstOffset - xOffset;
}
item1NextLeft = item1FirstPlace+Math.round(diffrence*drawHere.width()*1f);
item2NextLeft = item2FirstPlace-Math.round(diffrence*drawHere.width()*0.9f);
item3NextLeft = item3FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
item4NextLeft = item4FirstPlace-Math.round(diffrence*drawHere.width()*0.8f);
item5NextLeft = item5FirstPlace+Math.round(diffrence*drawHere.width()*0.7f);
item6NextLeft = item6FirstPlace-Math.round(diffrence*drawHere.width()*1f);
item7NextLeft = item7FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
item8NextLeft = item8FirstPlace-Math.round(diffrence*drawHere.width()*0.7f);
item9NextLeft = item9FirstPlace+Math.round(diffrence*drawHere.width()*0.6f);
item10NextLeft = item10FirstPlace-Math.round(diffrence*drawHere.width()*0.8f);
item11NextLeft = item11FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
//drawFrame();
//Toast.makeText(getApplicationContext(),"Offset Changed!!! xOffset : " + xOffset + "yOffset : " + yOffset + "xStep : " + xStep + "yStep : " + yStep + "xPixels : " + xPixels + "yPixels : " + yPixels ,Toast.LENGTH_SHORT).show();
//System.out.println("Offset Changed!!! xOffset : " + xOffset + "yOffset : " + yOffset + "xStep : " + xStep + "yStep : " + yStep + "xPixels : " + xPixels + "yPixels : " + yPixels );
}