Android Drawer with RecyclerView add footer at bottom - android

I'm trying to add footer at the bottom of my menu (facebook line).
I'm using drawer with recycler view for items in menu.
I have follow this tuto, just mod MyAdapter to detect footer and using footer layout in this case facebook line.
How can I have the last item of menu at bottom ?
Same as this but with recycler view

Just adjust your xml like this
<?xml version="1.0" encoding="utf-8"?>
<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_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_dark_menu"
android:elevation="7dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar" >
</include>
<FrameLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" />
</LinearLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start" >
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerView"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/grey_dark_menu"
android:scrollbars="vertical" >
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:id="#+id/footer_menu_facebook"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#508bc3"
android:orientation="horizontal"
android:padding="3dp" >
<ImageView
android:id="#+id/rowIcon"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="#drawable/menu_facebook" />
<TextView
android:id="#+id/rowText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:text="#string/footer_menu_facebook"
android:textColor="#android:color/white"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>

Related

How to add two Button in Navigation Drawer and on each Button show Different Menu Items

Please help me to make a navigation drawer with two menus and two different button to inflate the each Menu Items and click listener
Below is the Mock up and I want to make drawer like these
Navigation Drawer First Button View
Navigation Drawer Second Button View
Please check this, it will help to add a custom view. You can use tablayout and view pager
I have read your question very carefully and try to make this layout. Finally i make it .
try this code to achieve your layout
activity_home_navigation_activtiy
<?xml version="1.0" encoding="utf-8"?>
<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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_home_navigation_activtiy"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--<include layout="#layout/nav_header_home_navigation" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".28"
android:background="#color/colorPrimary"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingBottom="15dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/navigation_user_img"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/ic_launcher_foreground" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/navigation_user_name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Picks App"
android:textColor="#504C4C"
android:textSize="17dp"
android:textStyle="italic" />
<TextView
android:id="#+id/navigation_user_email_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Last Name"
android:textColor="#000"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/navigation_nested"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".72"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<Button
android:id="#+id/usr_bt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="User"/>
<Button
android:id="#+id/admin_bt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:text="Admin"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/user_recyler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:paddingLeft="15dp"
android:scrollbars="none" />
<android.support.v7.widget.RecyclerView
android:id="#+id/admin_recyler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:paddingLeft="15dp"
android:scrollbars="none" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
In this layout i try to make custom drawable . you can also customize according to your need
see screen shot
Thank You

How to start a recyclerview from below the toolbar

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

Vertical Scrolling Bar Does not show when scrolling Android

some what new to android development. Currently, this is the code that I have for my layout:
<FrameLayout 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:fitsSystemWindows="true"
android:theme="#android:style/Theme.NoTitleBar"
tools:context="com.alibaba.weex.com.alibaba.app.WXPageActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:scrollIndicators="right"
android:scrollbars="vertical">
</FrameLayout>
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
<TextView
android:id="#+id/index_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_below="#+id/index_progressBar"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:text="loading...."
android:visibility="gone" />
</FrameLayout>
Can someone help me figure out how to get the vertical scroll bar to show? I've tried changing the all the framelayouts to relativelayouts, and then changing the second framelayout to a ScrollView, but the app crashes once I open it.
Thanks!
I think your layout should be like this .
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scrollbars="vertical"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
</FrameLayout>
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
<TextView
android:id="#+id/index_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_below="#+id/index_progressBar"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:text="loading...."
android:visibility="gone" />
</FrameLayout>
</ScrollView>
You can't change scollview in the second framelayout because the scollview can only have one child .

Recyclerview is not shown when used swipe to refresh inside a Drawer layout

I was implementing a swipe to refresh the Relative layout inside a drawer layout
.It was all working fine before implementing the swipe to refresh once added it , the recyclerview element is not getting displayed
Am adding my layout below
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.pratheesh.madfest_sample.Mainpage"
android:background="#color/feed_bg"
android:id="#+id/drawerlayout"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/activity_madfext__toolbar"
android:id="#+id/mainpage_toolbar"
>
</include>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="80dp"
tools:context="com.example.pratheesh.madfest_sample.CardRow"
android:background="#drawable/feed_background"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:id="#+id/mainpage_add"
android:layout_below="#+id/mainpage_toolbar"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/feed_item_padding_top_bottom"
android:paddingTop="#dimen/feed_item_padding_top_bottom"
android:paddingLeft="#dimen/feed_item_padding_left_right"
android:paddingRight="#dimen/feed_item_padding_left_right" >
<com.example.pratheesh.madfest_sample.AspectRatioImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/images"
android:id="#+id/mainpage_imageview_profile1"
android:scaleType="fitCenter"
android:layout_centerVertical="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click to add Feeds"
android:id="#+id/mainpage_feeds"
android:textStyle="normal"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/mainpage_imageview_profile1"
android:layout_margin="5dp"
android:layout_marginTop="5dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_marginTop="0dp"
android:layout_below="#+id/mainpage_add"/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</FrameLayout>
</ScrollView>
<android.support.design.widget.NavigationView
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/navigationview"
app:menu="#menu/drawer"
app:headerLayout="#layout/activity_navigation_header"
app:itemTextAppearance="#style/NavigationDrawerStyle"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

Can't click children button in SlidingUpPanelLayout

I use SlidingUpPanelLayout in my project and i have a problem with it.
My SlidingUpPanelLayout has 2 children.
1) ListView for showing list of data - this is content
2) LinearLayout with his children (textvien, edittext, button) - this is slide up panel
When SlidingUpPanelLayout is showing i try to click on my button, and my SlidingUpPanelLayout immediately close, and i can't click on my button and edittext.
How can i get rid of this?
how can i setup click/show up panel on some View?
thanks!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:divider="#drawable/shape_divider_comments"
android:dividerHeight="1dp"
android:id="#+id/lvReviews"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<LinearLayout
android:id="#+id/rlSlidingContent"
android:gravity="center|top"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
style="#style/StyleEditText"
android:id="#+id/etPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/your_name_hint"
android:inputType="textPersonName" >
</EditText>
<Button
style="#style/StyleButton"
android:visibility="visible"
android:id="#+id/btnAddComment"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
Check out the method setDragView it represents the "handle" of the drawer.
Also, check the overdraw of your views, you could simplify your layout,
for example:
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/lvReviews"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#drawable/shape_divider_comments"
android:dividerHeight="1dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:visibility="gone" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/etPersonName"
style="#style/StyleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/your_name_hint"
android:inputType="textPersonName">
</EditText>
<Button
android:id="#+id/btnAddComment"
style="#style/StyleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Add"
android:visibility="visible" />
</LinearLayout>
</ScrollView>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
renders the same with far less overdraw

Categories

Resources