First look at an Android screen full screen implementation code
The code is as follows |
Copy Code |
@Override protected void OnCreate (Bundle savedinstancestate) { TODO auto-generated Method Stub Super.oncreate (savedinstancestate); Requestwindowfeature (Window.feature_no_title); GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_FULLSCREEN); GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); Setcontentview (r.layout.newslists); Newslistlayout = Findviewbyid (r.id.newslistlayout); Newslistlayout.setbackgroundcolor (Color.magenta); Newsnamelist = (ListView) Findviewbyid (r.id.newsnamelist); Model = new Model (0, 6); Namelistadapter = new Newsnamelistadapter (this, model); Newsnamelist.setadapter (Namelistadapter); ShowPage = (TextView) Findviewbyid (r.id.newslistshowpage); Updatepage (Model.getindex ()); } |
Now we can also judge whether it is full screen or not full-screen
The code is as follows |
Copy Code |
public void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (R.layout.main);
int v = This.getwindow (). GetAttributes (). Flags; Full Screen 66816-not full screen 65792 if (v!= 66816) {//Not full screen This.getwindow (). SetFlags ( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }else{//Cancel Full Screen This.getwindow (). Clearflags ( WindowManager.LayoutParams.FLAG_FULLSCREEN); } } |