I have this part of my layout:
<RelativeLayout
android:id="@+id/gameportView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="3dp"
android:background="@drawable/bg_container_rounded" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_centerInParent="true"
android:progress="0" />
<com.pepotegames.spotthedifferences.DifferenceView
android:id="@+id/imageA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/progressBar"
android:layout_centerHorizontal="true" />
<com.pepotegames.spotthedifferences.DifferenceView
android:id="@+id/imageB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/progressBar"
android:layout_centerHorizontal="true" />
</RelativeLayout>
I have a ProgressBar and two custom Views. In my activity I have a countdown timer wich I use to update my ProgressBar and a TextView:
timer = new CountDownTimer(level.getTimeC(),1000){
public void onTick(long millisUntilFinished){
level.setTimeC(millisUntilFinished);
labelClock.setText(formatTime(millisUntilFinished));
//bar.setProgress((int) (1000 - ((level.getTimeC() * 1000)/level.getTimeT())));
bar.setProgress((int) (level.getTimeT() - level.getTimeC()));
if(!hurryFlag){
if(level.getTimeC() <= level.getTimeH()){
hurryFlag = true;
labelClock.setTextColor(getResources().getColor(R.color.hurry));
ImageView sprite = (ImageView) findViewById(R.id.level_sprite_clock);
sprite.setImageResource(R.drawable.sprite_clock_hurry);
//tic-tac sound
}
}
}
public void onFinish(){
labelClock.setText("00:00");
bar.setProgress((int) level.getTimeT());
gameOver(false);
}
};
The problem is that when I call bar.setProgress() it causes the redraw of imageA too (but not imageB). I've read through the layout drawing cycle and it says that the parent gets drawed first and then the childs in topdown order. Thats why I placed my ProgresBar first.
I really need to avoid setProgress to cause the invalidation of imageA. Any ideas of how can I achieve this?
Thank you!