1

質問があります。プログレスバーが後方に移動しているように見えるタイマーがあります。今ではうまく機能するか、古い電話ではうまくいくはずですが、HD画面を備えた新しい電話ではうまく機能しません。タイマーバーは、私のxmlでvertとmatch_parentに設定されています。私は以下に私の方法を含めています。それを見て、どうすれば改善できるか教えていただけますか?

//used to animate timer bar
private Handler mHandler = new Handler();

//timer event code
private Runnable mUpdateTimeTask = new Runnable() {
       public void run() {
           final long start = startTime; 
// startTime will come from a spinner it will be 0,1,2,3,4 or 5 (users choice) 
// ** the bar is GREEN until the if condition is meet
           long currentLength = System.currentTimeMillis() - start;
           long remainingTime = gameTime - currentLength;
           float x = (float)remainingTime / (float)gameTime;

           if(remainingTime > 0)
           {
               //still have time remaining - update UI
               LinearLayout timerUI = (LinearLayout) findViewById(R.id.timerUI);
               timerUI.getLayoutParams().height =  (int) (x * 400);

               //update color
               if(remainingTime < 15000)
                  timerUI.setBackgroundColor(Color.RED);
               else if(remainingTime < 30000)
                   timerUI.setBackgroundColor(Color.YELLOW);

               timerUI.requestLayout();
               timerUI.invalidate();
               mHandler.postDelayed(this, 500);
           }
           else
           {
               if(monitorThread != null)
                   monitorThread.interrupt();

                //NEED to push user to final screen
                Intent resultsIntent = new Intent(SingleGameActivity.this, 
                    ResultsActivity.class);
                startActivity(resultsIntent);
           }
       }
    };
4

0 に答える 0