How to hide Items on recyclerview scrollbar gradually - android

How I can hide Items on recyclerview scrollbar gradually
I want like this Image
Tool Bar
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="#color/posts_toolbar"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<com.salah250.forvo.Funcations.TextViewFont
android:id="#+id/txt_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/posts_title"
android:textColor="#color/posts_title"
android:textSize="18dp" />
</android.support.v7.widget.Toolbar>
Activity Posts
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="#color/posts_main"
android:orientation="vertical"
tools:context=".Posts.PostsActivity">
<include layout="#layout/toolbar_posts" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_posts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
</LinearLayout>
I looked before I could post here and I could not find any topics talking about it at all, I hope to get some ideas for doing that.

You can put gradient image in front of your RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="#color/posts_main"
android:orientation="vertical"
tools:context=".Posts.PostsActivity">
<include layout="#layout/toolbar_posts" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_posts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
<ImageView
android:layout_width="match_parent"
android:layout_height="40dp"
android:src="#drawable/gradient"/>
<FrameLayout/>
</LinearLayout>
#drawable/gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="#00FFFFFF"
android:startColor="#302e43" />
</shape>
Then also add empty view with height of gradient to the header of your RecyclerView so topmost item will be not faded

Related

How do I get rid of this weird white background on my list view

I'm trying to make an Android version of my iOS app and I'm getting this weird white border around my list view and around my images on the list view that's super frustrating. Here's a screenshot:
Here's my code for the file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.example.leoconnelly.connexus.HealthCenterListActivity">
android:background="#D53D96"
<ListView
android:id="#+id/hospitals_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:background="#D53D96"
/>
</RelativeLayout>
You can delete android:layout_margin="8dp" from ListView or put the same background into it parent:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="#D53D96"
tools:context="com.example.leoconnelly.connexus.HealthCenterListActivity">
<ListView
android:id="#+id/hospitals_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:background="#D53D96"
/>
</RelativeLayout>

Tablayout Drop Shadow Disappears after I click another tab on Android Pre-lollipop

I am trying to create a drop shadow after the tablayout but it disappears right after I click another tab or I scrolled down the view pager beneath it. Here's what happens after I scroll it down.
The drop shadow appear after the first loading :
After I scrolled down, The drop shadow disappear :
After I click another tab, the drop shadow disappears as well :
But after I scrolled up again and clicked back to its first destination, the shadow appears again!
I already scoured over SO but I can seem to find an answer. Hope you guys can help me.
My code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_lane"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/lighter_purple_99"
android:elevation="4dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingTop="4dp">
<ImageView
android:id="#+id/img_lane_settings"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="right"
android:layout_marginRight="14dp"
android:src="#drawable/icn_settings" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
app:tabIndicatorColor="#color/white_100"
android:background="#color/lighter_purple_99"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:elevation="4dp"/>
<View
android:id="#+id/shadow_below_tabs2"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_below="#+id/tabs2"
android:background="#drawable/shadow"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tabs2"
android:keepScreenOn="true"
tools:context="TabActivity" />
</RelativeLayout>
The drawable/shadow.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#android:color/transparent"
android:endColor="#ff000000"
android:angle="90">
</gradient>
</shape>
I have already tried :
-- AppBarLayout but it there's a background on drop shadow so it looks ugly.
Hope you can help me. Thanks in advance!
Solved it!
Just put the shadow view under the viewpager. This way, the shadow will be the last one to be displayed and placed on top of the viewpager.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_lane"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/lighter_purple_99"
android:elevation="4dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingTop="4dp">
<ImageView
android:id="#+id/img_lane_settings"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="right"
android:layout_marginRight="14dp"
android:src="#drawable/icn_settings" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
app:tabIndicatorColor="#color/white_100"
android:background="#color/lighter_purple_99"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:elevation="4dp"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tabs2"
android:keepScreenOn="true"
tools:context="com.dojomadness.lolsumo.activities.LaneActivity" />
<View
android:id="#+id/shadow_view"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="#id/tabs2"
android:background="#drawable/shadow"
/>
</RelativeLayout>

Large gap between RecyclerView items

after I run my application I get large gap between RecyclerView items !!
this is my code here : Github
Large gap between recyclerview items
Change your Layouts like this
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.breuhteam.recyclerview.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
view_item.xml
<?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="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/itemView"
android:src="#drawable/diy"
android:layout_margin="1dp"
android:adjustViewBounds="true"/>
</RelativeLayout>

Android remove space between custom Toolbar and shadow with DrawerLayout

i'm using Linearlayout like with android Toolbar and i set custom shadow for that, unfortunately after opening DrawerLayout i have tiny space between custom toolbar and drawer layout and i can not fix this problem
CURRENT PROBLEM:
CORRECT VIEW:
My custom LinearLayout as an Toolbar with application_toolbar name:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="52dp"
android:background="#eaeaea"
android:gravity="center">
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
<pishguy.ir.asrebidree.Widgets.TextViewStyle
android:layout_width="100dp"
android:layout_height="fill_parent"
app:fonttype="mjbeirut"
android:text="#string/app_name"
android:textSize="20sp"
android:textColor="#737373"
android:gravity="right"
android:layout_marginRight="5dp"
android:paddingTop="7dp" />
</LinearLayout>
Activity main with drawerLayout and custom toolbar:
<LinearLayout 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/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- CUSTOM TOOLBAR -->
<include
android:id="#+id/toolbar"
layout="#layout/application_toolbar" />
<!-- TOOLBAR SHADOW -->
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="#drawable/toolbar_dropshadow" />
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp">
</android.support.v7.widget.RecyclerView>
...
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
Toolbar shadow:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#android:color/transparent"
android:endColor="#50949494"
android:angle="90"/>
</shape>
Change your activity main layout with DrawerLayout to the following and you will get the desired result.
<RelativeLayout 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/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- CUSTOM TOOLBAR -->
<include
android:id="#+id/toolbar"
layout="#layout/confirm_toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_below="#+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
<!-- TOOLBAR SHADOW -->
<View
android:layout_width="fill_parent"
android:layout_below="#+id/toolbar"
android:layout_height="5dp"
android:background="#drawable/toolbar_dropshadow" />
</RelativeLayout>
Change the Drawer layout to have a marginTop="-5dp". Basically because it's in a linear layout it will always be under the shadow. the -5dp will nudge it underneath the shadow.
Change the parent layout to be a RelativeLayout instead of a LinearLayout. Then you can nudge the Drawer to be just under it. Make sure you declare the shadow after the Drawer to make it draw last and on top of the Drawer.

How to add horizontal divider between action bar and layouts beneath it

How can I add a divider so that it appears underneath the action bar and above the master/detail panes? I've already defined the vertical divider but don't know how to define the horizontal divider also.
<LinearLayout 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"
android:orientation="horizontal"
android:divider="#drawable/divider_vertical"
android:showDividers="middle"
android:baselineAligned="false"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/master_container"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:id="#+id/detail_container"/>
</LinearLayout>
divider_vertical.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="1dp"/>
<solid android:color="#FFFFFF"/>
</shape>
divider_horizontal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:height="1dp"/>
<solid android:color="#FFFFFF"/>
</shape>
I do not see the code for the toolbar, so in my sense there should be a view below the toolbar as follows. I have used material design toolbar, you may use any toolbar.
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:theme="#style/Base.ThemeOverlay.AppCompat.Dark">
</android.support.v7.widget.Toolbar>
<View android:layout_height="0dp"
android:layout_width="fill_parent"
android:id="#+id/stripBelowToolbar"/>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
android:theme="#style/Theme.Insider.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:titleTextColor="#color/black"
android:elevation="0dp"
android:theme="#style/ToolbarColoredBackArrow"
android:background="#color/background_tint"
app:popupTheme="#style/Theme.Insider.PopupOverlay" />
<View
android:background="#color/lighter_color"
android:layout_width="match_parent"
android:layout_height="2dp"
/>
</com.google.android.material.appbar.AppBarLayout>
This worked for me

Categories

Resources