I've create a navigation drawer, but instead of putting a listview, I placed a relativelayout with two listviews inside
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#color/colorPrimary"
android:fitsSystemWindows="false"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:background="#color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<RelativeLayout
android:layout_gravity="start"
android:background="#color/nd_background"
android:layout_width="300dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:text="#string/app_name"
android:textColor="#color/nd_image_text"
android:gravity="bottom"
android:textSize="15sp"
android:padding="15dp"
android:background="#drawable/navigation_drawer_image"/>
<ListView
android:id="#+id/nd_list_1"
android:layout_below="#id/image"
android:dividerHeight="2dp"
android:divider="#color/white"
android:choiceMode="singleChoice"
android:drawSelectorOnTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:id="#+id/divider"
android:layout_below="#id/nd_list_1"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/darker_gray"/>
<ListView
android:id="#+id/nd_list_2"
android:layout_below="#id/divider"
android:divider="#color/white"
android:choiceMode="singleChoice"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Now I want to highlight a listview item when a specific row was selected, so I use the listview function setSelection, but the selected row does not get highlighted. I did work when I put only a listview into my navigation drawer, but not for this.
Related
i can' scroll my listView in DrawerLayout.
mycode activity_main:
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="#+id/drawerLayout"
tools:openDrawer="start"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
tools:context=".activities.MapActivity">
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:id="#+id/navigationViewRight"
android:layout_marginTop="30dp"
android:layout_marginBottom="5dp"
android:layout_height="match_parent"
android:layout_gravity="end">
<include
layout="#layout/layout_evennements"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.navigation.NavigationView>
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:id="#+id/navigationViewLeft"
android:layout_marginTop="30dp"
android:layout_marginBottom="5dp"
android:layout_height="match_parent"
android:layout_gravity="start">
<include
layout="#layout/layout_balises"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout >
my Layout_events code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:clickable="true"
android:id="#+id/layout_evennements"
android:theme="#style/Theme.GPRStest.NoActionBar"
android:layout_height="match_parent"
android:focusable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/dashmap2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/backgroundcolor"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_baseline_close_24"
android:layout_marginStart="15dp"
tools:ignore="ContentDescription" />
</LinearLayout>
<com.gabontech.gprstest.utils.ListViewForEmbeddingInScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ListView
android:id="#+id/listview_evennements"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_below="#id/dashmap2"
android:layout_marginRight="5dp"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#BFB9AF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#id/listview_evennements"
android:layout_gravity="center"
android:background="#color/white"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rien_a_voir"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:visibility="gone"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/noEventsData"/>
</RelativeLayout>
</RelativeLayout>
i would like to scroll mylistView but it does not scrolling.i use api to fetch data and display them in my ListView. then onDrawerOpen, ListView shows data but not scrolling. hope someone may help and bring a hand on it.
I have a toolbar and a recyclerview to show notification list when clicked on the badge on tool bar.but my recyclerview is overlapping the toolbar. I need the recycler to start below the toolbar so the user can close it by touching the badge again.how can I solve this problem, can anyone help out?
LAYOUT_FILE.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/dd_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NavigationDrawerActivity">
<LinearLayout
android:id="#+id/toollbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/navigation_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
<WebView
android:id="#+id/webViewID"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/left_drawer_parent"
android:layout_width="280dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="left|start">
<include
layout="#layout/drawer_header"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:paddingRight="10dp"
android:layout_gravity="left|start"
android:background="#color/gray"
android:choiceMode="singleChoice"
android:divider="#null"
android:scrollbars="vertical"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
</LinearLayout>
<RelativeLayout
android:id="#+id/rlNotificLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:padding="7dp"
android:visibility="gone" >
<android.support.v7.widget.RecyclerView
android:id="#+id/listView_Notific_Link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#c4c3bf"
android:scrollbars="vertical"
android:divider="#c4c3bf"
android:dividerHeight="7dp"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:paddingBottom="7dp"
/>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
You should use constraint layout: check out documentation here
Here's a nefty workaround on that. Set a top margin on your recyclerview. Use the layout_marginTop property and set it to ?actionBarSize. It should begin its layout below the toolbar.
You should use
app:layout_behavior="#string/appbar_scrolling_view_behavior"
inside your recyclerview
Try putting layout to the top. Topmost layout goes bottom.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/dd_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NavigationDrawerActivity">
<LinearLayout
android:id="#+id/toollbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/rlNotificLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#color/black"
android:padding="7dp"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="#+id/listView_Notific_Link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#c4c3bf"
android:divider="#c4c3bf"
android:dividerHeight="7dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingBottom="7dp"
android:scrollbars="vertical" />
</RelativeLayout>
<include
layout="#layout/navigation_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<WebView
android:id="#+id/webViewID"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/left_drawer_parent"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:orientation="vertical">
<include
layout="#layout/drawer_header"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#color/gray"
android:choiceMode="singleChoice"
android:divider="#null"
android:paddingRight="10dp"
android:scrollbars="vertical"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
You can use SlidingUpPanel layout.
https://github.com/umano/AndroidSlidingUpPanel
I have search a lot but not found same question on stack-overflow
Problem - I just want that only one view that scroll CoordinatorLayout similar
like handle view work in Sliding Panel layout
but in my current layout i have two views one is handle view (Textview with text "Route Plan") and other is RecyclerView What I want is when user click and drag on handle view CoordinatorLayout should scroll but when user click on RecyclerView it should not scroll CoordinatorLayout it shoud scroll only RecyclerView items is it possible
here is my current layout -
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_sub_tab"
android:padding="5pt"
tools:ignore="RtlHardcoded">
<android.support.design.widget.AppBarLayout
android:id="#+id/materialup.appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?colorPrimary"
app:expandedTitleMarginBottom="94dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/tvRoutePlan"
android:layout_alignParentTop="true"
android:gravity="top">
<RelativeLayout
android:id="#+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior"><!--com.indus.corelib.ui.FixedScrollingViewBehavior -->
<TextView
android:id="#+id/tvRoutePlan"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#drawable/map_list_title_gradient"
android:drawSelectorOnTop="true"
android:gravity="center_horizontal|center_vertical"
android:padding="5pt"
android:text="Route Plan"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="visible"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:nestedScrollingEnabled="false"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/white"
android:descendantFocusability="blocksDescendants"
android:divider="#android:color/darker_gray"
android:dividerHeight="#dimen/divider_height"
android:drawSelectorOnTop="true"
android:smoothScrollbar="true" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Note :- when i used other view insted of RecyclerView than it work perfectly as i want like when i click and drag that view CoordinatorLayout not move but i need recycler view there to show list :(
So try do something like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_sub_tab"
android:padding="5pt"
tools:ignore="RtlHardcoded">
<android.support.design.widget.AppBarLayout
android:id="#+id/materialup.appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?colorPrimary"
app:expandedTitleMarginBottom="94dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/tvRoutePlan"
android:layout_alignParentTop="true"
android:gravity="top">
<RelativeLayout
android:id="#+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior"><!--com.indus.corelib.ui.FixedScrollingViewBehavior -->
<TextView
android:id="#+id/tvRoutePlan"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#drawable/map_list_title_gradient"
android:drawSelectorOnTop="true"
android:gravity="center_horizontal|center_vertical"
android:padding="5pt"
android:text="Route Plan"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="visible"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:nestedScrollingEnabled="false"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/white"
android:descendantFocusability="blocksDescendants"
android:divider="#android:color/darker_gray"
android:dividerHeight="#dimen/divider_height"
android:drawSelectorOnTop="true"
android:smoothScrollbar="true" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
So remove recycleview from your layout behavior parent. Because the recycleview isnt inside the layout behavior parent he dont do the scroll flag. If this not Works the oter way is put the CoordinatorLayout inside other layout like a LinearLayout and recycleview outside CoordinatorLayout but inside LinearLayout.
Note: It's my idea i don't know if it Works.
Yup , I got the answer by myself
Just stop scroll of RecyclerView and it just work what i want
<android.support.v7.widget.RecyclerView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/white"
android:descendantFocusability="blocksDescendants"
android:divider="#android:color/darker_gray"
android:dividerHeight="#dimen/divider_height"
android:drawSelectorOnTop="true"
android:nestedScrollingEnabled="false"
android:overScrollMode="never"
android:fadeScrollbars="false"/>
also i used in java file
mListView = (RecyclerView) rootView.findViewById(android.R.id.list);
mListView.setNestedScrollingEnabled(false);
mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
mListView.stopScroll();
mListView.stopScroll() This is real game changer
But i am not happy that no one try to solve my prob except Bruno Ferreira :( Thanks Bruno for help
I have an activity, which hosts several fragments. This activity layout also contains a footer. One of the fragments has a ListView, which needs to be scrollable, as the last item appears behind the footer of the activity layout. The matter is that I wasn't able to make it scrollable. Here're my layouts:
Activity:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="#layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/fragment_container">
</FrameLayout>
</LinearLayout>
<include
layout="#layout/footer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#384554"
app:menu="#menu/navigation_drawer_resources"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
app:headerLayout="#layout/navigation_drawer_header"
app:theme="#style/MyNavigationDrawer"/>
</android.support.v4.widget.DrawerLayout>
My fragment:
<?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"
android:id="#+id/fragment_activities_catalogue">
<ImageView
android:layout_width="match_parent"
android:layout_height="70dp"
android:id="#+id/city_picture"
android:src="#drawable/city_header"
android:scaleType="fitStart"/>
<Button
android:layout_width="250dp"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:textAllCaps="false"
android:textColor="#android:color/white"/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="5dp"
android:background="#c4c4c4"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/listview"
android:layout_marginTop="8dp"
android:scrollbars="vertical"
android:smoothScrollbar="true">
</ListView>
</LinearLayout>
From the question what i understood is that your footer hides the last item of your list view ....
for this you can modify your layout like this
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_weight="0.85"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical">
<include
android:layout_weight="0.20"
layout="#layout/extra_tool"
android:layout_width="match_parent"
android:layout_height="0dp" />
<FrameLayout
android:layout_weight="0.80"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/fragment_container">
</FrameLayout>
</LinearLayout>
<include
android:layout_weight="0.15"
layout="#layout/extra_tool"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#384554"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
/>
</android.support.v4.widget.DrawerLayout>
Your first LinearLayout is "match_parent" so the footer is behind or before.
Give the LinearLayout an id("...topComponent...") and put the layout-attribute "layout_below="...topComponent..." to the footer include.
You have to try abit how to layout proper but the RelativeLAyout parent gives you all what you need. With the designer view you can check, how to put the attributes correct since you can see what happens directly.
Play with the layout attributes of the LinearLayout and the footer.
You are using DrawerLayout which by defaults receives all the touches, In
public boolean onNavigationItemSelected(MenuItem item){}, function return false in end instead of true.
Try if that works.
I am using the following layout. Basically, it has a custom toolbar, a Navigation Drawer, a menu, a ListView (listView1), and adlay.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/background">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/header_bg"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_above="#+id/adlay"
android:layout_margin="7dp"
android:cacheColorHint="#00000000"
android:divider="#android:color/transparent"
android:dividerHeight="3dp">
</ListView>
<LinearLayout
android:id="#+id/adlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
<ListView
android:id="#+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#eee"
android:dividerHeight="1dp"
android:background="#fff"
android:layout_below="#+id/toolbar"
>
</ListView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
The layout is kind of like the following order:
Toolbar (with Navigation drawer and menu)
listView1
adlay
listView1 consists of a list of items loaded from external XML files.
Problem is this. If listView1's items is not much, then it drops to the bottom, sitting above adlay, and there is a gap above listView1, between the toolbar and listView1. The display is like the following:
Toolbar (with Navigation drawer and menu)
GAP! <--- I don't want the gap to be here!
listView1
adlay
This is not desired display.
Ideally, I want the following:
Toolbar (with Navigation drawer and menu)
listView1
GAP should be here
adlay
Any help is much appreciated. Thanks.
i will write one layout file for your requirement. i hope it's usefull
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#android:color/black"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
<LinearLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_weight="1"
android:cacheColorHint="#00000000"
android:divider="#android:color/transparent"
android:dividerHeight="3dp">
</ListView>
<LinearLayout
android:id="#+id/adlay"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Adlay Layout"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:layout_gravity="start"
android:background="#fff"
android:choiceMode="singleChoice"
android:divider="#eee"
android:dividerHeight="1dp">
</ListView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>