FullScreenActivity.java的完整代码
/** * An example full-screen activity that shows and hIDes the system UI (i.e. * status bar and navigation/system bar) with user interaction. * * @see systemUIHIDer */public class FullscreenActivity extends Activity { /** * Whether or not the system UI should be auto-hIDden after * {@link #auto_HIDE_DELAY_MILliS} milliseconds. */ private static final boolean auto_HIDE = true; /** * If {@link #auto_HIDE} is set,the number of milliseconds to wait after * user interaction before hIDing the system UI. */ private static final int auto_HIDE_DELAY_MILliS = 3000; /** * If set,will toggle the system UI visibility upon interaction. Otherwise,* will show the system UI visibility upon interaction. */ private static final boolean TOGGLE_ON_CliCK = true; /** * The flags to pass to {@link systemUIHIDer#getInstance}. */ private static final int HIDER_FLAGS = systemUIHIDer.FLAG_HIDE_NAVIGATION; /** * The instance of the {@link systemUIHIDer} for this activity. */ private systemUIHIDer msystemUIHIDer; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_fullscreen); final VIEw controlsVIEw = findVIEwByID(R.ID.fullscreen_content_controls); final VIEw contentVIEw = findVIEwByID(R.ID.fullscreen_content); // Set up an instance of systemUIHIDer to control the system UI for // this activity. msystemUIHIDer = systemUIHIDer.getInstance(this,contentVIEw,HIDER_FLAGS); msystemUIHIDer.setup(); msystemUIHIDer .setonVisibilitychangelistener(new systemUIHIDer.OnVisibilitychangelistener() { // Cached values. int mControlsHeight; int mShortAnimTime; @OverrIDe @TargetAPI(Build.VERSION_CODES.HONEYCOMB_MR2) public voID onVisibilityChange(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { // If the VIEwPropertyAnimator API is available // (Honeycomb MR2 and later),use it to animate the // in-layout UI controls at the bottom of the // screen. if (mControlsHeight == 0) { mControlsHeight = controlsVIEw.getHeight(); } if (mShortAnimTime == 0) { mShortAnimTime = getResources().getInteger( androID.R.integer.config_shortAnimTime); } controlsVIEw .animate() .translationY(visible ? 0 : mControlsHeight) .setDuration(mShortAnimTime); } else { // If the VIEwPropertyAnimator APIs aren't // available,simply show or hIDe the in-layout UI // controls. controlsVIEw.setVisibility(visible ? VIEw.VISIBLE : VIEw.GONE); } if (visible && auto_HIDE) { // Schedule a hIDe(). delayedHIDe(auto_HIDE_DELAY_MILliS); } } }); // Set up the user interaction to manually show or hIDe the system UI. contentVIEw.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw vIEw) { if (TOGGLE_ON_CliCK) { msystemUIHIDer.toggle(); } else { msystemUIHIDer.show(); } } }); // Upon interacting with UI controls,delay any scheduled hIDe() // operations to prevent the jarring behavior of controls going away // while interacting with the UI. findVIEwByID(R.ID.dummy_button).setontouchListener( mDelayHIDetouchListener); } @OverrIDe protected voID onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Trigger the initial hIDe() shortly after the activity has been // created,to brIEfly hint to the user that UI controls // are available. delayedHIDe(100); } /** * touch Listener to use for in-layout UI controls to delay hIDing the * system UI. This is to prevent the jarring behavior of controls going away * while interacting with activity UI. */ VIEw.OntouchListener mDelayHIDetouchListener = new VIEw.OntouchListener() { @OverrIDe public boolean ontouch(VIEw vIEw,MotionEvent motionEvent) { if (auto_HIDE) { delayedHIDe(auto_HIDE_DELAY_MILliS); } return false; } }; Handler mHIDeHandler = new Handler(); Runnable mHIDeRunnable = new Runnable() { @OverrIDe public voID run() { msystemUIHIDer.hIDe(); } }; /** * Schedules a call to hIDe() in [delay] milliseconds,canceling any * prevIoUsly scheduled calls. */ private voID delayedHIDe(int delayMillis) { mHIDeHandler.removeCallbacks(mHIDeRunnable); mHIDeHandler.postDelayed(mHIDeRunnable,delayMillis); }}解决方法 如果我理解正确,你只想隐藏动作栏?
如果是,请更改此行(将flag_hIDe_navigation更改为0).
private static final int HIDER_FLAGS = 0;// systemUIHIDer.FLAG_HIDE_NAVIGATION;
并将其添加到onCreate调用中:
protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getwindow().requestFeature(Window.FEATURE_ACTION_bar); //new getActionbar().hIDe(); //new getwindow().setFlags( WindowManager.LayoutParams.FLAG_FulLSCREEN,WindowManager.LayoutParams.FLAG_FulLSCREEN); setContentVIEw(R.layout.activity_fullscreen);
之后,如果要显示动作栏,只需从活动中的任意位置调用:
getActionbar().show();总结
以上是内存溢出为你收集整理的android – 全屏活动向导活动.当我与设备进行互动时,如何停止显示动作栏?全部内容,希望文章能够帮你解决android – 全屏活动向导活动.当我与设备进行互动时,如何停止显示动作栏?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)