gmail like Progress bar functionality - android

I am creating a gmail like progress bar functionality. There seems to be some space between the actionbar and the progress bar.
Following is the code
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateOnly="true"
android:layout_width="wrap_content"
android:layout_height="?android:attr/actionBarSize" />
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>

DrawerLayout should contain only two children: FrameLayout for your content and fragment for drawer. Thus ProgressBar should be located inside dynamically created content.

To add a navigation drawer, declare your user interface with a DrawerLayout object as the root view of your layout. Inside the DrawerLayout, add one view that contains the main content for the screen (your primary layout when the drawer is hidden) and another view that contains the contents of the navigation drawer. for more Creating a Navigation Drawer.

Related

changing the list view of navigation drawer

I have a navigation drawer and I have 5 items in that. What I want to do is I want the first 3 items in the list to display from the top than a gap in between and the next two items to be displayed from the bottom of the drawer.
How can I do this?
Basically I want to how can I customise my drawer.
I also want to know from where I can make icons for my navigation drawer.
Here the snapshot to my drawer
link
I suppose this post will help you :) Just change DrawerLayout and put here whatever you want
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Relativelayout to display Lists -->
<RelativeLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Listview to display on top slider menu -->
<ListView
android:id="#+id/list_top_slidermenu"
android:layout_width="240dp"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:layout_gravity="start"
android:background="#color/list_background"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector" />
<!-- Listview to display on bottom slider menu -->
<ListView
android:id="#+id/list_bottom_slidermenu"
android:layout_width="240dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:background="#color/list_background"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
I think you need to use a custom adapter like always when you want to have something different from standard. There you can add customs views as well.
See my answer here https://stackoverflow.com/a/25086380/2777381. this is a sample of an custom adapter.
My idea would be to ad 3 custom listview items, with your icon, then an emty view with specific height. and then again some more custom list items.
Edit:
Sample of an "empty" View which i use as separator line:
<View
android:id="#+id/viewSeparator"
android:layout_below="#id/linearLayoutDrive"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="20dp"
android:background="#color/separator"/>

custom layout in navigation drawer

I am new to android, I follow this tutorial to create Navigation Drawer here
I make the navigation drawer successfully but I dont know how to change framelayout to my custom layout with button, textview....My app just show menu and blank framelayout, how can I solve this ?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="asdsadsad" />
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/purple_dark"
android:choiceMode="singleChoice"
android:divider="#android:color/darker_gray"
android:dividerHeight="0.1dp"
android:listSelector="#drawable/ic_drawer"/>
</android.support.v4.widget.DrawerLayout>
you can use a RelativeLayout on LinearLayout instead of FrameLayout and you can build your whole layout inside that
If you need to add another layout you need to gie it to your closeDrawerand drawerOpen.
Please refer my answer here

Navigation drawer like Google+

How can I create a navigation drawer like Google+ where there is a header for user profile info and a listview below?
I have the following code in my Activity:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.br.app.MainActivity">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment android:id="#+id/navigation_drawer"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:name="com.br.app.NavigationDrawerFragment" />
</android.support.v4.widget.DrawerLayout>
Currently, the NavigationDrawerFragment contains just a listview, but I tried to add a RelativeLayout as a container with an inner RelativeLayout to create the profile area and the listview below, but the app is crashing.
I've read the tutorial from but as I could understand, my header would be an item of the listview, and it won't be fixed on top (without scrolling).
How can I create this custom navigation drawer like Google+?
Actually, there are two version of navigation drawer used by google.
the first is the old navigation drawer BELOW the action bar. It is used in Google Play Store and Google Books for example.
HERE you can find a library that implements it.
The second is the new navigation drawer that is showed in Material Design guidelines where the drawer is over the action bar.
HERE you can find a library that implements it.
Actually these two libraries are in developing. But they are almost usable at this time.
You can easily customize the android Navigation drawer once you know how its implemented. here is a nice tutorial where you can set it up.
This will be the structure of your mainXML:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Listview to display slider menu -->
<ListView
android:id="#+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector"
android:background="#color/list_background"/>
</android.support.v4.widget.DrawerLayout>

how to use multiple fragments in the main content view of navigation drawer

I want to show two fragments (one listfragment and other is details fragment) in the main contentview of navigation drawer like below:
But AFAIK, there can be only one view in the main contentview of drawerLayout. So how can achieve this?
Anything you put inside the FrameLayout will be in the main content view.
You can put whatever you want (including multiple Fragments) inside this FrameLayout:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- YOUR CONTENT HERE -->
<!-- Could be layout with multiple views or fragments -->
</FrameLayout
<!-- The navigation drawer -->
<ListView android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>

How to add two fragments together in a frameLayout in runtime

I am developing an andorid application with navigation drawer and I have a layout for contentview like this:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:dividerHeight="0dp"
android:divider="#android:color/transparent"
android:background="#color/default_color"/>
</android.support.v4.widget.DrawerLayout>
So I can add and replace fragment on navigation drawer item click. Everything okay till now.
But in one case, on clicking an item on navigation drawer I need to show two fragments instead of one ( just like a listFragment and details fragment ). How can I do it? Should I add two fragments into the framelayout then? But how? or should I change the contentView with different drawerLayout ? If yes, how can I do this?
You may just use nested fragments. Create another fragment that will dynamically create both your fragments and add them to its layout.
For more information read this: http://developer.android.com/about/versions/android-4.2.html#NestedFragments

Categories

Resources