Tag: 电源管理

Android中状态栏中的动画

我是Android的新手。 我想在手机中制作电池充电动画 ,例如,在屏幕的右上角,小图标在充电时上下移动并停止当前电池百分比。 到目前为止,在我的代码中,我已经能够让它移动,但它永远不会停止。 我想要的是动画在没有充电时停止或者停在当前的电池百分比上。 这是动画中的代码: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.batteryinfo); ImageView batteryImage = (ImageView) findViewById(R.id.BatteryImage); batteryImage.setBackgroundResource(R.drawable.ic_battery_animation); BatteryAnimation = (AnimationDrawable) batteryImage.getBackground(); batteryImage.post(new Starter()); textBatteryLevel = (TextView) findViewById(R.id.batterylevel_text); registerBatteryLevelReceiver(); } class Starter implements Runnable { public void run() { BatteryAnimation.start(); } } 到目前为止,我可以获得电池状态,插头类型和电池的运行状况。