Skip to content

Commit 678c9e4

Browse files
author
jfeinstein10
committed
Fixed the ABS setSlidingActionBarEnabled(false) bug on pre-ICS devices
1 parent 86f9e87 commit 678c9e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

library/src/com/slidingmenu/lib/app/SlidingActivityHelper.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ public void onPostCreate(Bundle savedInstanceState) {
4040

4141
mOnPostCreateCalled = true;
4242

43+
// get the window background
44+
TypedArray a = mActivity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowBackground});
45+
int background = a.getResourceId(0, 0);
46+
4347
if (mEnableSlide) {
4448
mSlidingMenu.setFitsSystemWindows(true);
4549
// move everything into the SlidingMenu
4650
ViewGroup decor = (ViewGroup) mActivity.getWindow().getDecorView();
4751
ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
48-
TypedArray a = mActivity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowBackground});
49-
decorChild.setBackgroundResource(a.getResourceId(0, 0));
52+
// save ActionBar themes that have transparent assets
53+
decorChild.setBackgroundResource(background);
5054
decor.removeView(decorChild);
5155
mSlidingMenu.setViewAbove(decorChild);
5256
decor.addView(mSlidingMenu);
@@ -56,8 +60,12 @@ public void onPostCreate(Bundle savedInstanceState) {
5660
if (parent != null) {
5761
parent.removeView(mViewAbove);
5862
}
63+
// save people from having transparent backgrounds
64+
if (mViewAbove.getBackground() == null) {
65+
mViewAbove.setBackgroundResource(background);
66+
}
5967
mSlidingMenu.setViewAbove(mViewAbove);
60-
mActivity.getWindow().setContentView(mSlidingMenu);
68+
parent.addView(mSlidingMenu, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
6169
}
6270
}
6371

0 commit comments

Comments
 (0)