0

Hi I am using jfeinstein10/SlidingMenu library to implement the slide menu into my project.

HomePage.java

    import android.os.Bundle;
    import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
    import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;

     public class HomePage extends SlidingFragmentActivity {

    SlidingMenu menu;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_page);
        setBehindContentView(R.layout.behind);

        //customize the slide menu
        menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);       
        menu.setShadowWidthRes(R.dimen.shadow);
        menu.setFadeDegree(0.35f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        menu.setBehindOffsetRes(R.dimen.slidewidth);

    }
    }

XML Files :

activity_home_page.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

behind.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


</LinearLayout>

dimen.xml

  **<?xml version="1.0" encoding="utf-8"?>
<resources>

    <dimen name = "slidewidth">60dp</dimen>

    <dimen name="shadow">15dp</dimen>
</resources>**

My question is,

when run the app , I slide the screen, but the screen hide fully not as the offset set by the code

    menu.setBehindOffsetRes(R.dimen.slidewidth);

What I did wrong? Could any one help on this ?

Karthikeyan Ve
  • 2,550
  • 4
  • 22
  • 40

1 Answers1

0

You have given android:layout_width="match_parent" to LinearLayout in behind.xml

Give it wrap_content :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >

Hope it helps ツ

SweetWisher ツ
  • 7,296
  • 2
  • 30
  • 74