Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActionBar overlay problem. #174

Merged
merged 1 commit into from
Jun 24, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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