android - Change actionbar to overlay from within Fragment -


I have a piece (piece 1) that has been replaced by another volume (piece 2). The piece is placed on 1 stack. I'm using compatibility mode (not ActionBarSherlock)

Here's my problem. I want the taskbar to be displayed as an overlay in some pieces, but not in others. Specifically, when 2 pieces are shown, I want to show it in the overlay and then want to return to normal operation after a piece 2 goes out.

Piece 1 has a regular taskbar which is always visible but, when I change the fragment 1 with segment 2, then I need to hide the actionbars after 5 seconds. If there is a touch event, the operation has been shown again. It all works well, but, every time the proceedings are hidden or discovered, then section 2 is re-prepared. For this reason, I want to create an action bar in the frigate 2 show as an overlay.

I know that I can change the actionbar overlay, but I do not know how to program this from inside the piece. I do not want to change it for every piece, just segment 2

Thoughts

This is not the answer you were hoping for.

Consider a different question: Did we call setContentView (...) ? The question has been asked a number of times, and a normal solution is to recreate (calling finish () and startActivity (getIntent ()) ) and first new topic Set setContentView (...) .

Your question is an extension - with the complexity of changing theme from one piece to another. In any case, I do not consider the solution mentioned above in a good way.

The actionbase is one of the first components to start when the activity is created. I do not think you will find a way to 'refresh' somehow with new qualities. See below how requestFeature (Window.FEATURE_ACTION_BAR_OVERLAY) method deals with post-set contentview (...) calls:

  @ Override public boolean requestfeature (Int. Feature id) {if (mContentParent! = Tap) {new AndroidRuntimeException ("requestFeature () should be said before adding content"); } .... ....   

So, if setContentView (...) has already been called for activity (which is it Your case), a runtime-exception will be thrown.

Is it possible that you do not even need this functionality?

To show the action bar overlay in your theme:

  & lt; Item name = "android: windowActionBarOverlay" & gt; True & lt; / Item & gt; & Lt ;! - Support library for compatibility - & gt; & Lt; Item name = "windowActionBarOverlay" & gt; True & lt; / Item & gt;   

Here's my problem I want to show the action in some pieces as an overlay ...

OK . We are already provided for it.

... but not in others

Say that you do not want to have an action-line as an overlay in Fragment B. Then, in the layout of Fragment B., do the following:

  & lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: ID = "@ + ID / Drawer_layout" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: Layout_marginTop = "Android: ATR / Actionbirds" & gt; & Lt; & Lt; & Lt; -? Attr / actionBarSize for compatibility .... .... & lt; / LinearLayout & gt;   

With set top-margin set in the shape of the actionbars, the piece looks like B. It has a regular actionbase - not a single one, there will be another way to get it See android: layout_height = "Android: attr / actionBarSize" with as the first child in the layout given above.

In short:

  • Your actionbars will be an overlay.
  • In those pieces where ActionBar will automatically hide, the layout of pieces will not have no top-margin set. The top-margin set is set to actionBarSize in pieces of action where the ActionBar should not be overlaid.

    A point of note ( thanks for jell :

    If your actionbars semi transparent, it would be best to use padding instead of margin for a consistent form

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -