Я определил динамически все компоненты GUI. Когда Cntrl + F11 сначала нажимается, макет корректно переходит в вертикальную ориентацию. Но когда я снова нажимаю Cntrl + F11, раскладка остается в своем «ландшафтном» виде. Как я могу обновить его для "портретного" взгляда снова? Исходный код:
//Main Layout ll
LinearLayout ll ;
ll.setOrientation (LinearLayout.VERTICAL);
ll.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
//Inner layout ll2 is inside of the main layout ll
LinearLayout ll2 = new LinearLayout (this);
ll2.setWeight(1.0f);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
lp.weight = 0.25f;
//Button b is inside of the inner layout ll2
Button b = new Button (this);
b.setLayoutParams(lp);
ll2.addView (b);
ll.addView(ll2);
Я пробовал это решение (с этого сайта):
Я добавил функцию
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(ll);
}
и установите I в AndroidManifest
android:configChanges="keyboardHidden|orientation"
но это все равно не работает. Спасибо.