Я обнаружил, что установка размера окна работает, но вы должны сделать это чуть позже. В этом примере ширина окна установлена на 90% от ширины экрана, и это делается в onStart()
вместо onCreate()
:
@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 * 90 / 100;
LayoutParams layout = getWindow().getAttributes();
layout.width = Math.max(layout.width, new_window_width);
getWindow().setAttributes(layout);
}