I have an app in which I have a navigation panel with menu buttons on which I want to apply navigation drawer, currently it takes up the entire screen,but I want to restrict it to 3/4th of the screen by applying navigation drawer on it, but i have never touched navigation drawer before so have no clue, any help or guidance will be great.Also went through some documentation and got confused :( Here is my code:
and here is my layout class for navigation panel:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res/com.justin.a"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_texture"
android:clickable="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/nav_margin"
android:layout_marginTop="@dimen/nav_margin"
android:layout_marginRight="@dimen/nav_margin"
android:layout_marginBottom="@dimen/nav_margin"
android:background="#242424"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/nav_padding"
android:paddingTop="@dimen/nav_padding"
android:paddingRight="@dimen/nav_padding"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:drawable/divider_horizontal_bright"
android:orientation="vertical"
android:showDividers="middle"
>
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_dashboard"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
android:layout_marginBottom="1px"
android:onClick="onDashboardClicked"
android:text="@string/nav_option_dashboard"
android:textSize="@dimen/navigation_panel_text"
foo:customFont="cabin.medium.ttf"
android:padding="@dimen/nav_option_padding"
android:background="@drawable/nav_background_button"
/>
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_news"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
foo:customFont="cabin.medium.ttf"
android:textSize="@dimen/navigation_panel_text"
android:layout_marginBottom="1px"
android:onClick="onNewsClicked"
android:text="@string/nav_option_news"
android:padding="@dimen/nav_option_padding"
android:background="@drawable/nav_background_button"
/>
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_markets"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
android:textSize="@dimen/navigation_panel_text"
android:layout_marginBottom="1px"
android:onClick="onMarketClicked"
android:text="@string/nav_option_markets"
foo:customFont="cabin.medium.ttf"
android:padding="@dimen/nav_option_padding"
android:background="@drawable/nav_background_button"
/>
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_lists"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
android:textSize="@dimen/navigation_panel_text"
android:layout_marginBottom="1px"
android:text="@string/nav_option_lists"
foo:customFont="cabin.medium.ttf"
android:onClick="onListsClicked"
android:padding="@dimen/nav_option_padding"
android:background="@drawable/nav_background_button"
/>
<!-- UncommentForAlerts- Remove android:visibility="gone" -->
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_alerts"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
android:textSize="@dimen/navigation_panel_text"
android:layout_marginBottom="1px"
foo:customFont="cabin.medium.ttf"
android:padding="@dimen/nav_option_padding"
android:onClick="onAlertsClicked"
android:text="@string/nav_option_alerts"
android:background="@drawable/nav_background_button"
android:visibility="gone"
/>
<com.justin.a.utils.FontTextView
android:id="@+id/nav_option_briefcase"
style="@style/a.TextView.NavigationItem"
android:layout_width="match_parent"
android:layout_height="@dimen/button_ht"
android:textSize="@dimen/navigation_panel_text"
android:layout_marginBottom="1px"
foo:customFont="cabin.medium.ttf"
android:padding="@dimen/nav_option_padding"
android:onClick="onBriefcaseClicked"
android:text="@string/nav_option_briefcase"
android:background="@drawable/nav_background_button"
/>
</LinearLayout>
</ScrollView>
<ImageButton
android:id="@+id/button_information"
android:layout_width="@dimen/nav_button"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/nav_padding"
android:layout_centerHorizontal="true"
/>
<ImageButton
android:id="@+id/button_settings"
android:layout_width="@dimen/nav_button"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/nav_padding"
android:layout_toLeftOf="@+id/button_information" />
<ImageButton
android:id="@+id/button_logout"
android:layout_width="@dimen/nav_button"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/nav_padding"
android:layout_toRightOf="@+id/button_information"
/>
</RelativeLayout>
</RelativeLayout>
Also here is my navigationpanelfragment.java
:
--UPDATE----
public class NavigationPanelFragment extends Fragment implements OnClickListener {
public static final String TAG_NAVIGATION_PANEL_FRAGMENT = "NavigationPanelFragment";
public static final String ACTIVE_MENU_ITEM = "ActiveMenuItem";
private ActionBarDrawerToggle drawerToggle;
private Fragment lvDrawer;
public static void newInstance(final FragmentManager manager, final String activeFragmentTag) {
final NavigationPanelFragment fragment = new NavigationPanelFragment();
final Bundle arguments = new Bundle();
arguments.putString(NavigationPanelFragment.ACTIVE_MENU_ITEM, activeFragmentTag);
fragment.setArguments(arguments);
final FragmentInfo fragmentInfo = new FragmentInfo(TransactionMethods.ADD);
fragmentInfo.setAnimation(R.anim.slide_in_from_left, FragmentInfo.NO_ANIMATION);
fragmentInfo.setPopAnimation(0, R.anim.slide_out_to_left);
fragmentInfo.setFragmentTag(TAG_NAVIGATION_PANEL_FRAGMENT);
fragmentInfo.doNotAddToBackStack();
fragmentInfo.setActionBarTitle(Application.getAppResources().getString(R.string.title_applications));
FragmentStackManager.getInstance().transitionFragment(manager, fragment, fragmentInfo);
}
public static void removeInstance(final FragmentManager manager) {
Fragment fragment = manager.findFragmentByTag(TAG_NAVIGATION_PANEL_FRAGMENT);
if (fragment == null) {
return;
}
manager.beginTransaction().setCustomAnimations(0, R.anim.slide_out_to_left).remove(fragment).commitAllowingStateLoss();
}
private LogoutListener mLogoutListener = new LogoutListener() {
@Override
public void onLogoutOperationFired() {
final Activity activity = getActivity();
if(activity != null){
LoginActivity.newInstance(activity);
UserProfileManager.clearUserProfileManager();
FragmentStackManager.getInstance().clearBackStack(getFragmentManager());
activity.finish();
}
}
};
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
final View view = inflater.inflate(R.layout.fragment_navigation_panel, container, false);
return view;
}
@SuppressWarnings("deprecation")
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final ImageButton logoutButton = (ImageButton) getView().findViewById(R.id.button_logout);
logoutButton.setOnClickListener(this);
logoutButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_signout_nav_panel));
final ImageButton infoButton = (ImageButton) getView().findViewById(R.id.button_information);
infoButton.setOnClickListener(this);
infoButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_info_nav_panel));
final ImageButton settingsButton = (ImageButton) getView().findViewById(R.id.button_settings);
settingsButton.setOnClickListener(this);
settingsButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_prefs_nav_panel));
highlightActiveMenuItem();
}
@Override
public void onDestroy() {
super.onDestroy();
mLogoutListener = null;
}
@Override
public void onResume() {
MenuUtils.disableSearchMenu(getActivity());
MenuUtils.disableAlertMenu(getActivity());
super.onResume();
}
@Override
public void onPause() {
MenuUtils.enableSearchMenu(getActivity());
MenuUtils.enableAlertMenu(getActivity());
super.onPause();
}
@Override
public void onClick(final View v) {
switch (v.getId()) {
case R.id.button_logout:
final DialogFragment dialog = new LogoutCancelSignoutDialogFragment(mLogoutListener);
dialog.show(getActivity().getSupportFragmentManager(), AbsBaseaActivity.TAG_LOGOUT_DIALOG);
break;
case R.id.button_information:
leaveMainActivity();
InformationActivity.newInstance(getActivity());
break;
case R.id.button_settings:
leaveMainActivity();