Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

android - Hide ICS back home task switcher buttons

Just wondering how to hide the ICS back/home/etc software buttons programmatically. Just like the Youtube apps does when playing a video. I want to hide them while a video is playing, but bring them up if the user taps the screen.

I can't seem to find it anywhere on the web, or in Google's documentation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

pinxue is spot-on... you want SYSTEM_UI_FLAG_HIDE_NAVIGATION. Example:

myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

One thing to note, though, is that upon any (and I mean ANY) user interaction the navigation bar will be reshown.

With Honeycomb the closest you can get is to go into "lights out" mode (now called "low profile"... SYSTEM_UI_FLAG_LOW_PROFILE ). This just makes the items on the navigation bar less visible (the little "dots" you've probably seen). If you want to do the best you can at maintain backwards compatibility with Honeycomb you can use reflection to use the "best" method:

// Ask the System Bar to hide
int whichHiddenStatusToUse = android.view.View.STATUS_BAR_HIDDEN;
try {
    // if this next line doesn't thrown an exception then we are on ICS or  
    // above, so we can use the new field.
    whichHiddenStatusToUse = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(mDrawingSurface);
} catch (Exception ex) {
}
// now lets actually ask one of our views to request the decreased visibility
myView.setSystemUiVisibility(whichHiddenStatusToUse);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...