Re: [android-developers] Setting/Determining size of PopupWindow based on contents.

2014-06-24 Thread Kostya Vasilyev
Yes. You can use different MeasureSpec values depending on what you actually need (e.g. staying within a certain width). -- K 2014-06-24 7:23 GMT+04:00 Nathan nathan.d.mel...@gmail.com: Is this the idea? int widthSpec = MeasureSpec.UNSPECIFIED; int heightSpec =

[android-developers] Setting/Determining size of PopupWindow based on contents.

2014-06-23 Thread Nathan
I brought this up years ago. https://groups.google.com/forum/#!topic/android-developers/hZk5YYsmv_4 I want to either set or determine the size of the popupwindow. Is it still impossible? The size is not a constant. If I call mContentView.getWidth(); The first time it is zero. The second

Re: [android-developers] Setting/Determining size of PopupWindow based on contents.

2014-06-23 Thread Kostya Vasilyev
Just measure the popup's content view by calling contentView.measure with the appropriate MeasureSpec objects. Add padding from the popup's background, if appropriate. Viola! You have the exact size in pixels to use as the popup window's width and height. Some sample code from the framework

Re: [android-developers] Setting/Determining size of PopupWindow based on contents.

2014-06-23 Thread Nathan
Is this the idea? int widthSpec = MeasureSpec.UNSPECIFIED; int heightSpec = MeasureSpec.UNSPECIFIED; mContentView.measure(widthSpec, heightSpec); int W = mContentView.getMeasuredWidth(); int H = mContentView.getMeasuredHeight(); Doing that, I get actual