1

I have problem with animation in android.

My animations working good only on 1080x1920 480dpi display. But i don't know how made app for any display.

If I use method from http://www.i-programmer.info/programming/android/8797-android-adventures-beginning-bitmap-graphics.html?start=4 Animations run, ok but made shadows, so no rewrite display if I write on display something I not delete thise from display.

If I use method. Main activity have one threat

public class UpdateThread implements Runnable {      
    @Override
    public void run() {
        while(bez){
            try {
                myThread.sleep(50);
            } catch (Exception ex) {}                
            MainActivity.this.updateHandler.sendEmptyMessage(0);
        }
    }
and Class Game who every 50ms do

public void update() {
    x += 1;
    y += 2;
}
And on draw method in this class

protected void onDraw(Canvas canvas) {


    Plocha pozadie = new Plocha(paint, canvas, X0, Y0, vzdialenost);

    if (nehra==true) {
    paint.setStrokeWidth(13F);
    paint.setStyle(Paint.Style.STROKE);           

        LevelUp(level);          

        paint.setTypeface(Typeface.DEFAULT_BOLD);
        paint.setStyle(Paint.Style.FILL);
        pozadie.vypis(paint, canvas, "Score", 100, 100, 6);
        pozadie.vypis(paint, canvas, Integer.toString(zasah), 90, 200, 9);
        pozadie.vypis(paint, canvas, "Level", 850, 100, 6);
        pozadie.vypis(paint, canvas, Integer.toString(level), 850, 200, 8);
        pozadie.vypis(paint, canvas, "Clicks", 1080 / 2 - 100, 100, 7);
        pozadie.vypis(paint, canvas, Integer.toString(click), 1080 / 2, 200, 9);

}

everything be okay (y) but only one type display.

If use

Bitmap b = Bitmap.createBitmap(1080,
            1920,Bitmap.Config.ARGB_8888);
    this.canvas = new Canvas(b);
    this.canvas.drawColor(Color.WHITE);
    this.b=b;

and rewrite some parts of code

application result is these canvas

protected void onDraw( Canvas canvas ) { I don't know why...

ImageView im=(ImageView)findViewById(R.id.imageView222);

    game = new Game(this,im);
    setContentView(game);

I think so If I save setContentView(game); to imageview. will be everything okay. But I try and every ideas finish more errors.

I'm sad from...

Thanks from some ideas.

adda
  • 33
  • 6
  • What is the result on a different display? Are you maybe looking for just http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels ? – zapl Jun 02 '16 at 11:09

0 Answers0