I am creating a sliding menu drawer in my application...the problem is when i am sliding the menu it is sliding the heading too wheres i just want the content to move with the slider. how can i prevent header from moving. i am using fragments for my code:
MainActivity :
setContentView(R.layout.layout_home);
ButterKnife.inject(this);
btnMenu.setVisibility(View.VISIBLE);
homeScreenFragment = new HomeScreenFragment();
getSupportFragmentManager().beginTransaction()
.replace(R.id.frameLayout, homeScreenFragment).commit();
// configure the SlidingMenu menu = new SlidingMenu(this);
menu=new SlidingMenu(this);
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_frame);
getSupportFragmentManager().beginTransaction()
.replace(R.id.menu_frame, new HomeNavFragment()).commit();
findViewById(R.id.imgBtnMenu).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
menu.toggle(true);
}
});
HomeScreenFragment:
public final String[] podName = new String[] { "NO Text", "NO Text",
"NO Text", "NO Text" };
public final Integer[] images = { R.drawable.pod_img1, R.drawable.pod_img2,
R.drawable.pod_img3, R.drawable.pod_img1 };
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.layout_homescreen, container,
false);
ButterKnife.inject(this, view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
addItemsToListView();
}
private void addItemsToListView() {
rowItems = new ArrayList<RowItem>();
for (int i = 0; i < podName.length; i++) {
RowItem item = new RowItem(images[i], podName[i]);
// RowItem item = new RowItem(imageUrl[i], deityName[i]);
rowItems.add(item);
}
setAdapter();
}
private void setAdapter() {
CustomBaseAdapter adapter = new CustomBaseAdapter(getActivity(), rowItems);
podListView.setAdapter(adapter);
}
Navigation Fragment:
public static final String[] nav_title = new String[] { "CLE & Events",
"Pictorial Roster", "Publications", "On-Demand CLE", "Court Info",
"LBA Alerts", "My Profile", "Notification Settings",
"App Support & Feedback", "Share this App", "Developer", " ", " " };
public static final int[] nav_icon = { R.drawable.ic_menu_calender,
R.drawable.ic_menu_roster, R.drawable.ic_menu_publication,
R.drawable.ic_menu_filebox, R.drawable.ic_menu_court,
R.drawable.ic_menu_bubble, R.drawable.ic_menu_profile,
R.drawable.ic_menu_reminder, R.drawable.ic_menu_share,
R.drawable.ic_menu_developer, R.drawable.ic_menu_developer,
R.drawable.ic_menu_developer };
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.layout_homescreen, container,
false);
ButterKnife.inject(this, view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
setAdapter();
/*addItemsToListView();*/
}
private void setAdapter() {
NavigationMenuAdapter adapter = new NavigationMenuAdapter(getActivity(),nav_title,nav_icon);
podListView.setAdapter(adapter);
}
Xml:
layout_home:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="@+id/header_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="@layout/include_header" />
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header_home">
</FrameLayout>
</RelativeLayout>
layout_homescreen
<ListView
android:id="@+id/podListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:listSelector="@android:color/transparent" >
</ListView>
</LinearLayout>
menu.xml
Since you want to move your content area with sidepanel + ActionBar should remain static, best way would be to implement v4 widget SlidingPaneLayout (android.support.v4.widget.SlidingPaneLayout).
here is a good example that explains how to implement SlidingPaneLayout
And please go through Developer's site for proper understanding.
Hope it helps..!! :)