Skip to content

Commit

Permalink
Fix ActionBar overlay problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodev authored and goodev committed Apr 17, 2014
1 parent 0957a7e commit 994633d
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
Expand Down Expand Up @@ -212,6 +213,7 @@ private void addCroutonToView(final Crouton crouton) {
return;
}
handleTranslucentActionBar((ViewGroup.MarginLayoutParams) params, activity);
handleActionBarOverlay((ViewGroup.MarginLayoutParams) params, activity);

activity.addContentView(croutonView, params);
}
Expand Down Expand Up @@ -261,6 +263,23 @@ private void handleTranslucentActionBar(ViewGroup.MarginLayoutParams params, Act
}
}

@TargetApi(11)
private void handleActionBarOverlay(ViewGroup.MarginLayoutParams params, Activity activity) {
// ActionBar overlay is only available as of Android 3.0 Honeycomb.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final boolean flags = activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
if (flags) {
final int actionBarContainerId = Resources.getSystem().getIdentifier("action_bar_container", "id", "android");
final View actionBarContainer = activity.findViewById(actionBarContainerId);
// The action bar is present: the app is using a Holo theme.
if (actionBarContainer != null) {
final ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) params;
marginParams.topMargin = actionBarContainer.getBottom();
}
}
}
}

/**
* Removes the {@link Crouton}'s view after it's display
* durationInMilliseconds.
Expand Down

0 comments on commit 994633d

Please sign in to comment.