如何在Android中将倒计时屏幕设置为主屏幕壁纸。

时间:2011-11-05 13:23:41

标签: android

在我的应用程序中,我为剩余的日子制作一个倒计时屏幕(比如直到圣诞节的倒计时),现在我想将该屏幕作为主屏幕壁纸。

像这样:

enter image description here

2 个答案:

答案 0 :(得分:4)

如果您在文本框中显示时间,那么您也可以尝试使用此代码..

class UpdateTimeTask extends TimerTask {
   public void run() {
       long millis = System.currentTimeMillis() - startTime;
       int seconds = (int) (millis / 1000);
       int minutes = seconds / 60;
       seconds     = seconds % 60;

       timeLabel.setText(String.format("%d:%02d", minutes, seconds));
   }
}

http://developer.android.com/resources/articles/timed-ui-updates.html

答案 1 :(得分:1)

嗨,如果你想要一个静态的背景图片,你可以做这样的事情并放入主应用程序的onCreate:

// Set background image, rotatable
    View view = getWindow().getDecorView(); 
    int orientation = getResources().getConfiguration().orientation; 
    if (Configuration.ORIENTATION_LANDSCAPE == orientation) { 
        view.setBackgroundResource (R.drawable.yourimage); // Landscape
    } else { 
        view.setBackgroundResource (R.drawable.yourimgae); // Portrait
    } 
相关问题