Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active October 4, 2017 12:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexfu/8422694 to your computer and use it in GitHub Desktop.
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.
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