Smooth transition of layout size using streams

I am changing the height and width of the layout programmatically. This changes, but the problem is that they don't change smoothly since I am using a stream. I want the layout size (height and width) to have a smooth transition. this is my code:

 final Handler handler = new Handler();
 Runnable runable = new Runnable() 
 {
     @Override
     public void run() {
         try {
             Log.d("This is working", "This is working");
             handler.postDelayed(this, 100);
             if ((w >= minWidth) && (w < maxWidth) && (toggle == 1)) {
                 w++;
                 h++;
                 if (w == maxWidth) {
                     toggle = 0;
                 }
             } else {
                 w--;
                 h--;
                 if (w == minWidth) {
                     toggle = 1;
                 }
             }
             View view_instance = (View) findViewById(R.id.surface);
             LayoutParams params = view_instance.getLayoutParams();
             params.width = w;
             params.height = h;
             view_instance.setLayoutParams(params);
         } catch (Exception e) {
             // TODO: handle exception
         } finally {
             //also call the same runnable 
             handler.postDelayed(this, 100);
         }
     }
 };
 handler.postDelayed(runable, 100);

      

thank

+3
android multithreading transition delay


source to share


No one has answered this question yet

Check out similar questions:

1989
"implements Runnable" vs "extends Thread" in Java
1487
What is the difference between a process and a thread?
1266
How do I update the GUI from another thread?
1192
How do I use streams in Python?
1002
Grid motion detection
862
What are the "tools: context" in android layout files?
815
Android "Only the original thread that created the view hierarchy can touch its views."
761
What is daemon thread in Java?
715
Multiprocessing vs Threading Python
674
What is thread safe or unsafe thread in PHP?



All Articles
Loading...
X
Show
Funny
Dev
Pics