Android view re-creation on orientation change
-
26-10-2019 - |
문제
I want to do something like in iPhone development: reposition controls manually without recreating the whole view. what are pros and cons of this approach?
해결책
Hopefully this will be useful for somebody.
if you don't want ro re-create your view on orientation change, the only thing you need is to change corresponding Activity in manifest file like this:
android:configChanges="keyboardHidden|orientation|keyboard"
if you want to reposition controls manually, override onConfigurationChanged and reposition everything you need there
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// reposition and/or hide/show controls here
}
제휴하지 않습니다 StackOverflow