Last active
October 4, 2017 12:48
-
-
Save alexfu/8422694 to your computer and use it in GitHub Desktop.
Example that shows how to determine if the ActionBar is currently in overlay mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
if(windowActionBarOverlay()) { | |
// Do something | |
} | |
} | |
private boolean windowActionBarOverlay() { | |
TypedValue attributeValue = new TypedValue(); | |
getTheme().resolveAttribute(android.R.attr.actionBarStyle, attributeValue, true); | |
TypedArray a = getTheme().obtainStyledAttributes(attributeValue.data, new int[] {android.R.attr.windowActionBarOverlay}); | |
boolean isOverlaid = a.getBoolean(0, false); | |
a.recycle(); | |
return isOverlaid; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment