2010-06-26 53 views
1

时钟我打算显示时钟以这种方式如何显示这样

alt text http://i48.tinypic.com/iylezo.jpg

我的时钟做..我不知道如何让小文“PM”像上面的图片。

也为星期一星期二星期三....

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"); 
} 

等等。

回答

1

上午/下午指标应该是一个单独的TextView,在布局的适当位置,与较小android:textSize。至少,我是这么做的。

如果我误解了你的问题,我很抱歉,但很难通过“最小化文本”来确定你的意思。

+0

谢谢=)..然后,我怎么能创造那样的日子(周日,周一,周二......) – 2010-06-26 10:00:09

+1

@mgpyone:七个'TextViews',改变文字颜色的透明度(和也许使当前的一个也大胆)。 – CommonsWare 2010-06-26 10:45:03

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()); 
    } 
    } 
    } 
} 
相关问题