I have an Activity with a dialog theme (Theme.Holo.DialogWhenLarge). It appears too narrow, and I'd like it to fill up a larger percentage of the screen. I am trying to accomplish this by overriding the windowMinWidthMinor and windowMinWidthMajor attributes. 
The theme used by my Activity looks like this...
<style name="MyTheme" parent="@android:style/Theme.Holo.DialogWhenLarge">
    <item name="android:windowMinWidthMajor">90%</item>
    <item name="android:windowMinWidthMinor">90%</item>
</style>
However, it seems like the windowMinWidthMajor and windowMinWidthMinor have no effect. Can anybody explain what I'm doing wrong? 
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Some code here
        setWindowHeight(90);
    }
    /**
     * Set percentage width height
     * @param percent percent from current size. From 0 to 100.
     */
    private void setWindowHeight(int percent){
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        int screenHeight = metrics.heightPixels;
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.height = (int)(screenHeight*percent/100);
        this.getWindow().setAttributes(params);
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With