How do I set the maximum width of a ViewGroup? I am using a Theme.Dialog activity, however, this does not look so good when resized to bigger screens, it’s also sort of lightweight and I don’t want it taking up the whole screen.
I tried this suggestion to no avail. Also, there is no android:maxWidth property like some views.
Is there a way to restrict the root LinearLayout so that it is only (for example) 640 dip? I am willing to change to another ViewGroup for this.
Any suggestions?
One option which is what I did is to extend LinearLayout and override the onMeasure function. For example:
Then you XML would use the custom class:
And the attr.xml file entry
EDIT: This is the actual code I am using now. This is still not complete but works in most cases.