1

我打算用这种方式显示时钟

替代文字

我已经完成了时钟..我不确定如何获得上面图片中的小文本“PM”。

也适用于 MON TUE WED ....

Calendar c = new GregorianCalendar();

 if(c.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
    System.out.println("MON");
} else if (c.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY){
        System.out.println("TUE");
}

等等。

4

2 回答 2

1

AM/PM 指示器应该只是一个单独TextView的 ,位于布局中的适当位置,带有较小的android:textSize. 至少,我会这样做。

如果我误解了您的问题,我深表歉意,但很难确定您所说的“最小化文本”是什么意思。

于 2010-06-26T09:50:12.857 回答
0
private ImageView img;
 Handler mHandler;

 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  Thread myThread = null;

  Runnable runnable = new CountDownRunner();
  myThread = new Thread(runnable);
  myThread.start();

 }

 public void doRotate() {

  runOnUiThread(new Runnable() {
   public void run() {
    try {

     Date dt = new Date();
     int hours = dt.getHours();
     int minutes = dt.getMinutes();
     int seconds = dt.getSeconds();
     String curTime = hours + ":" + minutes + "::" + seconds;
     Log.v("log_tag", "Log is here Time is now" + curTime);
     img = (ImageView) findViewById(R.id.imgsecond);
     RotateAnimation rotateAnimation = new RotateAnimation(
       (seconds - 1) * 6, seconds * 6,
       Animation.RELATIVE_TO_SELF, 0.5f,
       Animation.RELATIVE_TO_SELF, 0.5f);

     rotateAnimation.setInterpolator(new LinearInterpolator());
     rotateAnimation.setDuration(1000);
     rotateAnimation.setFillAfter(true);

     img.startAnimation(rotateAnimation);
    } catch (Exception e) {

    }
   }
  });
 }

 class CountDownRunner implements Runnable {
  // @Override
  public void run() {
   while (!Thread.currentThread().isInterrupted()) {
    try {

     doRotate();
     Thread.sleep(1000);
    } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
    } catch (Exception e) {
     Log.e("log_tag", "Error is " + e.toString());
    }
   }
  }
 }
于 2013-01-31T06:13:18.157 回答