Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android, how to re-layout views?

Tags:

android

I am adding a series of custom views to a LinearLayout. I have overridden the onMeasure method of these custom views, to return the dimensions based on certain parameters. Based on user input, I would like to change these parameters, to change the size of the views. How can I force the LinearLayout to "re-layout" it's children, to reflect the new dimensions?

like image 433
ab11 Avatar asked Nov 23 '10 15:11

ab11


People also ask

How do you refresh a layout?

Android provides a widget that implements the swipe-to-refresh design pattern, which allows the user to trigger an update with a vertical swipe. This is implemented by the SwipeRefreshLayout widget, which detects the vertical swipe, displays a distinctive progress bar, and triggers callback methods in your app.

Which layout is best in Android?

Use FrameLayout, RelativeLayout or a custom layout instead. Those layouts will adapt to different screen sizes, whereas AbsoluteLayout will not. Definitely right. I recommend RelativeLayout since it keeps the view hierachy flat.


1 Answers

Oh... linearLayout.requestLayout().

like image 116
ab11 Avatar answered Oct 06 '22 00:10

ab11