Maveňツ
Maveňツ

Reputation: 1

how to stop sliding by dragging the main page to right

I have done MenuSlider but i just want to slide when actionBar home button is clicked how to do so i m not getting any idea to resolve this issue since i have to add 4 tabs then navigation to them seems difficult

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    StrictMode.enableDefaults();


    Drawable d=getResources().getDrawable(R.drawable.action_bar);  

    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    //actionBar.setTitle("Action Bar");
    actionBar.setLogo(R.drawable.transparent);
    //actionBar.setSubtitle("http://www.android.com");
    actionBar.addOnMenuVisibilityListener(this);
    actionBar.setBackgroundDrawable(d);


    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(true);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    getActionBar().setHomeButtonEnabled(true);
    getOverflowMenu();

    setBehindContentView(R.layout.left_tab);
    setSlidingActionBarEnabled(true);
    slideMenu = getSlidingMenu();
    slideMenu.setMode(SlidingMenu.LEFT);
    slideMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slideMenu.setShadowWidthRes(R.dimen.slidingmenu_offset);
    //slideMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    slideMenu.setBehindOffset(80);
    slideMenu.setFadeDegree(0.99f);

    inflater = getLayoutInflater();
    //item = inflater.inflate(R.layout.left_tab, null);}
}

Upvotes: 1

Views: 370

Answers (1)

Maveňツ
Maveňツ

Reputation: 1

Try Changing

slideMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

to

slideMenu.setTouchModeAbove(SlidingMenu.ABOVE); 

touchModeAbove - an enum that designates what part of the screen is touchable when the above view is showing. Margin means only the left margin. Fullscreen means the entire screen. Default is margin.


Simple Example

public class SlidingExample extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.attach);
    // set the content view
    setContentView(R.layout.content);
    // configure the SlidingMenu
    SlidingMenu menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.menu);
}

}

XML Usage

If you decide to use SlidingMenu as a view, you can define it in your xml layouts like this:

<com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
    xmlns:sliding="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingmenulayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    sliding:viewAbove="@layout/YOUR_ABOVE_VIEW"
    sliding:viewBehind="@layout/YOUR_BEHIND_BEHIND"
    sliding:touchModeAbove="margin|fullscreen"
    sliding:behindOffset="@dimen/YOUR_OFFSET"
    sliding:behindWidth="@dimen/YOUR_WIDTH"
    sliding:behindScrollScale="@dimen/YOUR_SCALE"
    sliding:shadowDrawable="@drawable/YOUR_SHADOW"
    sliding:shadowWidth="@dimen/YOUR_SHADOW_WIDTH"
    sliding:fadeEnabled="true|false"
    sliding:fadeDegree="float"
    sliding:selectorEnabled="true|false"
    sliding:selectorDrawable="@drawable/YOUR_SELECTOR"/>

This class was deprecated in API level 17. This class is not supported anymore. It is recommended you base your own implementation on the source code for the Android Open Source Project if you must use it in your application.

Output:

enter image description here

Upvotes: 1

Related Questions