navigation-drawer

Android set navigation drawer list to open exact half of the screen for all device screen

五迷三道 提交于 2019-12-02 20:15:47
I want to open the drawerlist to the half of the screen for all different device. i tried hard coded values for layout_margineleft 200dp or 100dp to the drawerlist. but it doesn't work in all device it different from device to device. so how can i maintain the exactly half of the screen for drawerlist. i also tried various function like setLeft(int) etc.but some of them doesn't work due to i use minimum version 8. So please help me. thanks in advance. mDrawerLayout = (DrawerLayout) view.findViewById(R.id.drawer_layout); mDrawerList = (ListView) view.findViewById(R.id.top_sectionlist); xml for

How to close navigation drawer when an item is pressed from it?

我只是一个虾纸丫 提交于 2019-12-02 19:54:42
Ideally navigation drawer should get closed once some item has been pressed from it, but its not happening automatically. How to do it ? Thanks! Vipul J Got it! private DrawerLayout mDrawerLayout; mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.closeDrawers(); Working perfectly fine. For me this one worked - mDrawerLayout.closeDrawer(Gravity.START, false); Ashif closeDrawer(); // called when you want to close public void closeDrawer() { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } } On the right bottom

How to expand navigation list in action bar?

淺唱寂寞╮ 提交于 2019-12-02 19:41:04
In android you could set a navigation list in action bar by passing spinner adapter and OnNavigationListener. the issue is that the navigation list dont fill most of the action bar, how to make it expand like the gmail app : Example of Gmail app : My app: And here's the code : //... setting the array adapter ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); NavigationListener navigationListener = new NavigationListener(); ListAdapter listAdapter = new ListAdapter(); actionBar.setListNavigationCallbacks(listAdapter, navigationListener); actionBar

mimicking the navigation drawer of youtube/gmail app

☆樱花仙子☆ 提交于 2019-12-02 19:37:34
Background In the recent months Google released the Youtube app with navigation drawer (AKA sliding menu). it has many cool features that i wish to have on an app i'm working on. the features are: touch anywhere to start sliding. moving icon on the "up" button of the action bar when switching modes. content area (the area on the right, not the menu itself) stays instead of scrolling, when sliding the menu. action bar stays instead of scrolling. content area (the area on the right, not the menu itself) changes its color when scrolling, and not the menu itself. here are screenshots to show what

Activity in fragment class

孤街浪徒 提交于 2019-12-02 19:24:13
问题 So i created a navigationDrawer and i have a problem I need to put my activity ActivitySec package com.calculatorvamal.app; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; public class SecondAct2 extends Activity implements TextWatcher {

fragments - how to use them with activities that require actions?

坚强是说给别人听的谎言 提交于 2019-12-02 19:15:00
问题 First - apologies for the newbie question. I'm trying to implement a Navigation Drawer that will be used across my app. To start, I've followed the Android tutorial and created a basic navigation which changes a with Fragments. I can pass a framelayout id and fragment to FragmentTransaction. It works great. I decided to create a new login activity with the default android files (In Android Studio: going to new - activity - login activity ). This is what's confusing me. My questions are: Can I

Navigation drawer starts from right side

此生再无相见时 提交于 2019-12-02 18:03:06
问题 How can i make the navigation drawer open from the right to the left? Main.xml <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="end" app:headerLayout="@layout/drawer_header" app:menu="@menu/navigation" android:background="#FFE7FF"/> drawer_header.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android

Android: Is it better to create a new fragment every time a navigation drawer item is clicked, or load up previously created fragments?

℡╲_俬逩灬. 提交于 2019-12-02 18:02:22
I am implementing the standard navigation drawer pattern for android, with about 10 fragments the user can navigate to from the drawer. Currently, I am creating a new Fragment every time a different navigation drawer item is clicked like so: // When a new navigation item at index is clicked FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); Fragment newFragment = null; if (index == 0) fragment = new Fragment0(); ... ft.replace(R.id.container, newFragment); ft.commit(); I have been wondering if it would be more efficient to

navigation drawer not showing properly

帅比萌擦擦* 提交于 2019-12-02 17:59:46
问题 I am developing news app and I have implemented navigation drawer using following link but when I run the code app showing empty white screen. below my MainActivity.java class public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawer; private Toolbar toolbar; private ActionBarDrawerToggle drawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set a Toolbar to replace

Drawer toggle button not displaying on Action Bar

独自空忆成欢 提交于 2019-12-02 17:52:47
问题 I have two activities in my app and both have navigation drawers implemented. Now the scenario is that the Drawer toggle is getting displayed for the first activity but for the same code its not getting displayed for the second activity (which is getting called from the first activity). I don't have much experience in Android Programming and I am stuck on this one. Please help anyone :( Here's the Java Code snippet to display drawer toggle button: DrawerLayout drawer = (DrawerLayout)