android: set layout dimension, center it and set to fullscreen in combination does not work? -
i want set width , height of window, center , set fullscreen hide top bar.
with these lines can set dimension , set fullscreen centering takes no effect.
window window = getwindow(); window.setgravity(gravity.center | gravity.fill_vertical | gravity.fill_horizontal); window.setlayout(480, 320); window.requestfeature(window.feature_no_title); window.addflags(windowmanager.layoutparams.flag_fullscreen);
following sets dimension , centers top bar visible fullscreen takes no effect.
window window = getwindow(); window.setgravity(gravity.center); window.setlayout(480, 320); window.requestfeature(window.feature_no_title); window.addflags(windowmanager.layoutparams.flag_fullscreen);
and fanally if add
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar.fullscreen">
the window centered, dimensions set , fullscreen… first time launch app. after app closed , started again, isn't fullscreen anymore.
how can achieve sized, centered window in fullscreen?
@edit: figured out if exit app device button works always. top bar gets visible if quit app home button.
so don't have solution small hack. following destroys app when home button pressed. forces app restart , hide top bar again. i'm not happy hack works now.
/* * (non-javadoc) * * @see android.app.activity#onstop() */ @override protected void onstop() { super.onstop(); //hack prevent stopping fullscreen mode if home button pressed activitymanager = (activitymanager) .getsystemservice(activity_service); list<activitymanager.runningtaskinfo> taskinfo = am.getrunningtasks(1); componentname componentinfo = taskinfo.get(0).topactivity; if(componentinfo.getshortclassname().equalsignorecase(".launcher")) { ondestroy(); } } @override public void ondestroy() { super.ondestroy(); system.runfinalizersonexit(true); system.exit(0); }
Comments
Post a Comment