If I place the pictures with different resolution into different drawable folders, it will not stretch and it will select the pictures from one of the drawable folders. However, the pictures still come out off.
If I place the pictures into only 1 drawable folder, for some reasons, the pictures will be stretched way bigger than the actual phone size. It's like I can only see the middle part of the pictures.
I also noticed frames being skipped.
Could someone please give me some advices?
Thank you and I very appreciate for your help.
main class:
public class main_activity extends WallpaperService {
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public Engine onCreateEngine() {
eturn new wallpaperEngine();
}
class wallpaperEngine extends Engine implements
SharedPreferences.OnSharedPreferenceChangeListener{
private final Handler mhandler = new Handler();
private final Runnable drawrunnable = new Runnable()
{
public void run() {
drawFrame();
}
};
private boolean mVisible;
private SharedPreferences mPrefs;
private int i = 0;
int[] pirates = {
};
wallpaperEngine()
{
mPrefs = main_activity.this.getSharedPreferences(SHARED_PREFS_NAME, 0);
mPrefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(mPrefs, null);
}
public void onSharedPreferenceChanged(SharedPreferences mPrefs2, String key) {
}
@Override
public void onCreate(SurfaceHolder holder){
super.onCreate(holder);
}
@Override
public void onDestroy() {
super.onDestroy();
mhandler.removeCallbacks(drawrunnable);
}
@Override
public void onVisibilityChanged(boolean visible) {
mVisible = visible;
if (visible) {
drawFrame();
} else {
mhandler.removeCallbacks(drawrunnable);
}
}
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
super.onSurfaceChanged(holder, format, width, height);
drawFrame();
}
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
super.onSurfaceCreated(holder);
}
@Override
public void onSurfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
super.onSurfaceDestroyed(holder);
mVisible = false;
mhandler.removeCallbacks(drawrunnable);
}
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xStep,float yStep, int xPixels, int yPixels) {
drawFrame();
}
@Override
public void onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
}
private void drawFrame() {
// TODO Auto-generated method stub
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
drawPirate(c);
}
} finally {
if (c != null)
holder.unlockCanvasAndPost(c);
}
mhandler.removeCallbacks(drawrunnable);
if (mVisible) {
mhandler.postDelayed(drawrunnable);
}
}
private void drawPirate(Canvas c) {
// TODO Auto-generated method stub
Bitmap icon;
c.drawBitmap(icon, matrix, null);
icon.recycle();
}
}
}
Edit: fixed title
Edit: I removed Paint in Black. It's not supposed to be there