Hi, (Not global, just for your case following the code you written in your fist post)
[code] button.setLayoutParams(new LinearLayout.LayoutParams(100,200)); Log.v(TAG, "Size = "+button.getLayoutParams().width + "," + button.getLayoutParams().height); [/code] getWidth and getHeight will not work here, as there is one UI thread. So, the button will not be redrawn while the tasks inside the event handler for the second button is not finished. So, the button will be redrawn with new size after fully executing the onClick handler of the other button, you are calling the time to execute the full handler "a very short timespan." Regards Sarwar Erfan On Aug 4, 6:10 pm, Jan Meskens <[email protected]> wrote: > I am calling the setLayoutParams in a click event of another button. > The button size is being changed visually, but also after a very short > timespan. > > Jan > > On 4 aug, 13:57, Sarwar Erfan <[email protected]> wrote: > > > Hi, > > Is your button size being changed visually? (just to make sure) > > > And, where are you calling the setLayoutParams method? In some event? > > > Regards > > Sarwar Erfan > > > On Aug 4, 5:16 pm, Jan Meskens <[email protected]> wrote: > > > > Thanks for your reply. But the problem is that this solution can only > > > be applied to custom widgets (which are subclassed fromt View) and > > > thus can override the protected onSizeChanged. > > > > How can I do it for existing widgets without making a custom class? > > > > Jan > > > > On 4 aug, 12:23, Sarwar Erfan <[email protected]> wrote: > > > > > protected void onSizeChanged (int w, int h, int oldw, int oldh) > > > > > On Aug 4, 2:30 pm, Jan Meskens <[email protected]> wrote: > > > > > > Hi all, > > > > > > I am currently looking for a way to detect that a view has been > > > > > resized. It seems that there is some time between calling a resize > > > > > method and when it is actually resized > > > > > > For example: > > > > > > [code] > > > > > //I give a certain width and height > > > > > button.setLayoutParams(new LinearLayout.LayoutParams(100,200)); > > > > > //Now, I check the components width and height > > > > > Log.v(TAG, "Size = "+button.getWidth() + "," + button.getHeight()); > > > > > [/code] > > > > > > Unfortunately, the received width and height is still the old one. I > > > > > already tried to call button.invalidate(), but this doesn't solve the > > > > > problem either... . > > > > > > Is there any workaround to receive a components height/width right > > > > > after it has been resized? In java awt/swing there is the > > > > > ComponentListener (http://download.oracle.com/javase/6/docs/api/java/ > > > > > awt/event/ComponentListener.html) for resolving these problems. Is > > > > > there any alternative available in Android? > > > > > > Cheers, > > > > > Jan -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

