Code example for RelativeLayout

Methods: clearAnimation, getLayoutParams, setLayoutParams, setVisibility, startAnimation

0
			 
			battbar.setLayoutParams(baseparam);
			battbar.setBackgroundColor(colour);
			//this.setLayoutParams(baseparam1a); 
			 
			ViewGroup.LayoutParams baseparamc = chargeholder.getLayoutParams();
			Boolean pulse = true;
			// Bullet / Pulse Animation 
			// Leaves artifacts behind.... so true for now. 
			if (pulse) {
				RelativeLayout.LayoutParams align = new RelativeLayout.LayoutParams(
						baseparamc);
				align.height = height;
				align.width = width - ((batteryLevel * width) / 100);
				Log.d("battbar", "" + battbar.getId());
				align.addRule(RelativeLayout.RIGHT_OF, battbar.getId());
				chargeholder.setLayoutParams(align);
				charge.setBackgroundColor(colour);
			} else if (!pulse) {
				RelativeLayout.LayoutParams align = new RelativeLayout.LayoutParams(
						baseparamc);
				align.height = height;
				align.width = 5;
				align.addRule(RelativeLayout.ALIGN_LEFT);
				chargeholder.setLayoutParams(align);
				// setDisplayedChild(indexOfChild(chargeholder)); 
				// bringChildToFront(chargeholder); 
				charge.setBackgroundColor(0xaFFFFFFF);
			} 
 
			// animate? stop animation? 
			if (batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING
					|| batteryStatus == BatteryManager.BATTERY_STATUS_FULL) {
				if (!mRunning) {
					start(); 
				} 
			} else { 
				if (mRunning) {
					stop(); 
				} 
			} 
		} else { 
			this.setVisibility(View.GONE);
		} 
		// was having issues with alignment 
		// battbar.setGravity(Gravity.LEFT | Gravity.TOP); 
		// charge.setGravity(Gravity.LEFT | Gravity.TOP); 
	} 
 
	@Override 
	public boolean isRunning() { 
		return mRunning;
	} 
 
	@Override 
	public void start() { 
 
		if (Settings.System.getInt(getContext().getContentResolver(),
				"battery_bar_anim_on", 0) == 1) { 
			Boolean pulsing = true;
			if (pulsing) {
				mRunning = true;
				anim_mode = Settings.System.getInt(getContext()
						.getContentResolver(), "anim_type", FLAG_MODE_ACLDCL);
				pulse_mode = Settings.System.getInt(getContext()
						.getContentResolver(), "anim_pulse_type", FLAG_PULSE);
				ScaleAnimation anim = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f);
				anim.setDuration(INT_ANIM_DURATION);
				if (anim_mode == FLAG_MODE_ACLDCL) {
					anim.setInterpolator(new AccelerateDecelerateInterpolator());
				} else if (anim_mode == FLAG_MODE_ACL) {
					anim.setInterpolator(new AccelerateInterpolator());
				} else if (anim_mode == FLAG_MODE_DCL) {
					anim.setInterpolator(new DecelerateInterpolator());
				} else { 
					anim.setInterpolator(new LinearInterpolator());
				} 
				if (pulse_mode == FLAG_PULSE) {
					anim.setRepeatMode(Animation.REVERSE);
				} else { 
					// anim.setRepeatMode(Animation.REVERSE); 
				} 
				Log.d("battbar", "start anim");
				anim.setRepeatCount(Animation.INFINITE);
 
				chargeholder.setVisibility(View.VISIBLE);
				chargeholder.startAnimation(anim);
			} else if (!pulsing) {
				mRunning = true;
				anim_mode = Settings.System.getInt(getContext()
						.getContentResolver(), "anim_type", FLAG_MODE_ACLDCL);
				pulse_mode = Settings.System.getInt(getContext()
						.getContentResolver(), "anim_pulse_type", FLAG_PULSE);
				TranslateAnimation anim = new TranslateAnimation(0,
						((batteryLevel * width) / 100) - 5, 0, 0);
				anim.setDuration(INT_ANIM_DURATION);
 
				if (anim_mode == FLAG_MODE_ACLDCL) {
					anim.setInterpolator(new AccelerateDecelerateInterpolator());
				} else if (anim_mode == FLAG_MODE_ACL) {
					anim.setInterpolator(new AccelerateInterpolator());
				} else if (anim_mode == FLAG_MODE_DCL) {
					anim.setInterpolator(new DecelerateInterpolator());
				} else { 
					anim.setInterpolator(new LinearInterpolator());
				} 
 
				if (pulse_mode == FLAG_PULSE) {
					anim.setRepeatMode(Animation.REVERSE);
				} else { 
					// anim.setRepeatMode(Animation.REVERSE); 
				} 
				Log.d("battbar", "start anim");
				anim.setRepeatCount(Animation.INFINITE);
 
				chargeholder.setVisibility(View.VISIBLE);
				chargeholder.startAnimation(anim);
			} 
		} 
	} 
 
	@Override 
	public void stop() { 
		mRunning = false;
		// stop the animation. 
		chargeholder.clearAnimation();
		Log.d("battbar", "stop anim");
		// hide the layout in-case it is a bad size after stopping. 
		chargeholder.setVisibility(View.GONE);
	} 
 
	class SettingsObserver extends ContentObserver {
		public SettingsObserver(Handler handler) {
			super(handler);