Strange offset behavior on slidingmenu

≯℡__Kan透↙ 提交于 2019-12-04 20:21:50

That´s what I use:

// customize the SlidingMenu
        setBehindContentView(R.layout.menu_frame);
        FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
        mFrag = new SlidingFragment();
        t.replace(R.id.menu_frame, mFrag);
        t.commit();

                SlidingMenu sm = getSlidingMenu();
                sm.setShadowWidthRes(R.dimen.shadow_width);
                sm.setShadowDrawable(R.drawable.shadow);
                sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
                sm.setFadeDegree(0.35f);
                setSlidingActionBarEnabled(true);

                getSupportActionBar().setDisplayHomeAsUpEnabled(true);

dimen.xml

<resources>

    <dimen name="slidingmenu_offset">60dp</dimen>
    <dimen name="list_padding">10dp</dimen>
    <dimen name="shadow_width">15dp</dimen>

    <integer name="num_cols">1</integer>

</resources>

Sample:

https://www.4shared.com/rar/zOWrvmyu/ViewpagerandSherlock.html

This sample is perfectly working viewpager and sherlock.

Just implement this code in BaseSampleActivity extends SlidingFragmentActivity, create a simple SlidingFragment and it will works.

You need to extend a SlidingMenu class. To also use the ActionBar Sherlock library you must follow the steps listed in the Readme, in particular this one:

Go into the SlidingActivities that you plan on using make them extend Sherlock__Activity instead of __Activity.

So your project should extend SlidingActivity:

public class Waiter extends SlidingActivity {

And you need to change your copy of the SlidingMenu library to use ABS. Open com/slidingmenu/lib/app/SlidingActivity.java and change:

public class SlidingActivity extends Activity implements SlidingActivityBase {

to:

public class SlidingActivity extends SherlockActivity implements SlidingActivityBase {
//             Add "Sherlock" here:  ^^^^^^^^

(Repeat this step for any other SlidingMenu Activities you wish to use.)

This answer isn´t necessary so I edited to focus other one!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!