Let me rewrite this --- lol:

Pre-ICS, the size of a dialog was wrapped around its body View.  On
ICS this is no longer the case, but, instead, every dialog has a
minimum width which is almost the compete widh of screen of a Galaxy
Nexus in potrait mode.  Is
there a way to force the WRAP_CONTENT on ICS?

The following doesn't work:

dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT),
LayoutParams.WRAP_CONTENT);


What works is this terrible hacky code, but I couldn't come up with a
better solution:


ViewParent parent = bodyView.getParent();


if (parent != null)  {


    parent = parent.getParent();
    if (parent != null) {


        parent = parent.getParent();
        if ((parent != null) && (parent instanceof ViewGroup))   {


            LayoutParams layoutParams =
((View)parent).getLayoutParams();
            if (layoutParams instanceof FrameLayout.LayoutParams) {


                 layoutParams.width =
ViewGroup.LayoutParams.WRAP_CONTENT;
                 ((FrameLayout.LayoutParams)layoutParams).gravity =
Gravity.CENTER_HORIZONTAL;
                 ((View)parent).setLayoutParams(layoutParams);
            }
       }
   }



Anybody has any ideas?

-- 
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

Reply via email to