File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import com .actionbarsherlock .app .ActionBar .TabListener ;
99import com .actionbarsherlock .view .Menu ;
1010import com .actionbarsherlock .view .MenuItem ;
11+ import com .slidingmenu .lib .SlidingMenu ;
1112import com .slidingmenu .lib .app .SlidingListActivity ;
1213
1314public class ExampleActivity extends SlidingListActivity implements TabListener {
@@ -18,6 +19,7 @@ public void onCreate(Bundle savedInstanceState) {
1819 setBehindContentView (R .layout .main2 );
1920 getSlidingMenu ().setBehindOffsetRes (R .dimen .actionbar_home_width );
2021 getSlidingMenu ().setBehindScrollScale (0.5f );
22+ getSlidingMenu ().setAboveTouchMode (SlidingMenu .TOUCHMODE_FULLSCREEN );
2123 ActionBar actionBar = getSupportActionBar ();
2224 actionBar .setNavigationMode (ActionBar .NAVIGATION_MODE_TABS );
2325 actionBar .setDisplayHomeAsUpEnabled (true );
Original file line number Diff line number Diff line change @@ -1182,11 +1182,44 @@ private void completeScroll() {
11821182 }
11831183 }
11841184
1185+ private int mAboveTouchMode = SlidingMenu .TOUCHMODE_MARGIN ;
1186+ private int mBehindTouchMode = SlidingMenu .TOUCHMODE_MARGIN ;
1187+
1188+ public void setAboveTouchMode (int i ) {
1189+ mAboveTouchMode = i ;
1190+ }
1191+
1192+ public int getAboveTouchMode () {
1193+ return mAboveTouchMode ;
1194+ }
1195+
1196+ public void setBehindTouchMode (int i ) {
1197+ mBehindTouchMode = i ;
1198+ }
1199+
1200+ public int getBehindTouchMode () {
1201+ return mBehindTouchMode ;
1202+ }
1203+
11851204 private boolean thisTouchAllowed (float x ) {
11861205 if (isMenuOpen ()) {
1187- return x >= getBehindWidth () && x <= getWidth ();
1206+ switch (mBehindTouchMode ) {
1207+ case SlidingMenu .TOUCHMODE_FULLSCREEN :
1208+ return true ;
1209+ case SlidingMenu .TOUCHMODE_MARGIN :
1210+ return x >= getBehindWidth () && x <= getWidth ();
1211+ default :
1212+ return false ;
1213+ }
11881214 } else {
1189- return x >= 0 && x <= mSlidingMenuThreshold ;
1215+ switch (mAboveTouchMode ) {
1216+ case SlidingMenu .TOUCHMODE_FULLSCREEN :
1217+ return true ;
1218+ case SlidingMenu .TOUCHMODE_MARGIN :
1219+ return x >= 0 && x <= mSlidingMenuThreshold ;
1220+ default :
1221+ return false ;
1222+ }
11901223 }
11911224 }
11921225
Original file line number Diff line number Diff line change 99import android .widget .RelativeLayout ;
1010
1111public class SlidingMenu extends RelativeLayout {
12+
13+ public static final int TOUCHMODE_FULLSCREEN = 0 ;
14+ public static final int TOUCHMODE_MARGIN = 1 ;
1215
1316 private CustomViewAbove mViewAbove ;
1417 private CustomViewBehind mViewBehind ;
@@ -156,4 +159,28 @@ public void setBehindScrollScale(float f) {
156159 mViewAbove .setScrollScale (f );
157160 }
158161
162+ public int getAboveTouchMode () {
163+ return mViewAbove .getAboveTouchMode ();
164+ }
165+
166+ public void setAboveTouchMode (int i ) {
167+ if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN ) {
168+ throw new IllegalStateException ("TouchMode must be set to either" +
169+ "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN." );
170+ }
171+ mViewAbove .setAboveTouchMode (i );
172+ }
173+
174+ public int getBehindTouchMode () {
175+ return mViewAbove .getBehindTouchMode ();
176+ }
177+
178+ public void setBehindTouchMode (int i ) {
179+ if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN ) {
180+ throw new IllegalStateException ("TouchMode must be set to either" +
181+ "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN." );
182+ }
183+ mViewAbove .setBehindTouchMode (i );
184+ }
185+
159186}
You can’t perform that action at this time.
0 commit comments