2

I feel that I have tried anything to get my dialog fill about 75% (width) of the screen, when it starts. It was always looking great, but since I upgraded to Android 4.4 I cannot get my dialogs to look "normal" but instead they are very small.

When I open a dialog I use the Theme.Holo.DialogWhenLarge as the theme for an activity. All my dialogs are started as activities. I want them to be fullscreen on mobile devices and a dialog (popup) on tablets.

I tried the tips from the following post, but none seem to work:

This issue is driving me nuts... Any advice?

Community
  • 1
  • 1
JBernhardt
  • 414
  • 3
  • 7
  • Please post the relevant parts of your code. Without seeing what you're doing, it's impossible to offer advice. – Ted Hopp Sep 15 '14 at 20:28

1 Answers1

3

I don't know what's wrong with me... ;-) It looks like that as soon as I post a question, I find a working solution:

@Override
protected void onStart() {
   super.onStart();
   // In order to not be too narrow, set the window size based on the screen resolution:
   final int screen_width = getResources().getDisplayMetrics().widthPixels;
   final int new_window_width = screen_width * 75 / 100; 
   LayoutParams layout = getWindow().getAttributes();
   layout.width = Math.max(layout.width, new_window_width); 
   getWindow().setAttributes(layout);
}

I'm still not 100% happy with my solution, because I would like to avoid custom code to get the right screen size, but I guess I do have to work more on my layout. But for now, this solution is working for me.

JBernhardt
  • 414
  • 3
  • 7