alexfu
1/14/2014 - 5:57 PM

Example that shows how to determine if the ActionBar is currently in overlay mode.

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;
  }

}