Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird updateViewLayout behaviour

Tags:

android

layout

I have a view (custom drawn) added with getWindowManager().addView() and later I'm modifiying the LayoutParameters of it (changing x & width) and call getWindowManager().updateViewLayout(). This works but I am getting two screen refreshes, first one only moves the whole thing according to the new x and later one scales it according to the new width. Any ideas about why is this happening even though I only call updateViewLayout just one time with the new layout parameters?

FYI: onDraw method of the custom drawn view mentioned here is also called only one time by the system during this process.

like image 635
volution Avatar asked Jun 09 '11 21:06

volution


1 Answers

Try:

runOnUiThread(new Runnable() {
      public void run() {
          view.updateViewLayout();
       }
    });

http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)

If it doesn't work, check this:

How to move a view in Android?

Are you doing this?

like image 100
neteinstein Avatar answered Nov 19 '22 09:11

neteinstein