I have a RecyclervView with a rounded Drawable background and .clipToOutline = true in order to keep the overscroll animation inside the background. When I set requiresFadingEdge="vertical", there's a glitch where the fading edge is; example below. How can I fix this? The issue doesn't appear when I set .clipToOutline = false or when I don't have a fading edge, but I would like both of these effects. Thanks for the help.
You can see the issue in the bottom corners of the blue RecyclerView.
This can be fixed by setting a different layer type either in xml, or programatically when initialising your recyclerview:
XML
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layerType="hardware"
...
Programatically
recyclerView.setLayerType(VIEW.LAYER_TYPE_HARDWARE, null)
You can also use LAYER_TYPE_SOFTWARE, but it's better to use LAYER_TYPE_HARDWARE for performance reasons.
Find out more about this 2 options in these docs:
https://developer.android.com/reference/android/view/View#LAYER_TYPE_HARDWARE
https://developer.android.com/reference/android/view/View#LAYER_TYPE_SOFTWARE
Related
Before you start:
I'm using Kotlin
I'm using ConstraintLayout (switching to LinearLayout or RelativeLayout is not an option)
I have my layout as follows:
<TextView android:id="#+id/myRefer" .../>
<ScrollView
...
app:layout_constraintTop_toBottomOf="#id/myRefer">
...
</ScrollView>
And my animation is developed as follows:
myRefer.animate()
.translationY(-myRefer.height.toFloat())
.alpha(0.0f)
So far so good, no problem with the animation, everything goes as expected.
The problem is, I thought that from the moment I'm using TranslateY, the ScrollView would follow the new position reference (topToBottom). But it keeps a white hole (as if my TextView is still using the reference height)
Did I misunderstand the use of TranslateY, or am I using animate() incorrectly? How would I solve this problem for my ScrollView to follow the reference.
Note: Don't suggest using onAnimatonEnd and setting View.GONE, it just makes things worse.
I would just use android:animateLayoutChanges="true" on the layout. And then instead of animate... just call myRefer.visibility = View.VISIBLE or View.GONE. It will have the same effect and the Scrollview will adjust to the hidden element.
I have a listview with overscroll mode on - (I need it on)
And there is a blue overscroll glow everytime I overscroll
how do I get rid of the overscroll glow ?
EDIT:
I am using a custom listview that streches the overscroll drawable (picture) - the way it should be
however, along with the picture there is a glowing effect which i want to get rid of
see the blue thing above the image?
the image IS the overScrollDrawable - but i want the same thing - without the glow
android:overScrollMode="never"
You just need to set your ListView property fadeEdge to none in your layout xml file and you will not get the shadow blue on OVERSCROLL.
android:fadingEdge="none"
EDIT:
this is now deprecated, you can use android:overScrollMode="never" instead.
In the ListView you can set the drawable when overscrolling on top or bottom. This is usually set to a white/transparent drawable that is animated with fadeIn and fadeOut. To set the glowing to something fully transparent you can write:
ListView listView = ...;
listView.setOverscrollFooter(new ColorDrawable(0));
listView.setOverscrollHeader(new ColorDrawable(0));
This keeps the overscroll itself active, so that you can react on overscrolling events, but the glowing should be gone.
I am working on an android app and I have a scrollview, and in that, I have a linear layout in the main activity. I want to have the top and bottom borders of the linear layout to be "faded
" so as the user scrolls down the child views in the layout will "fade out" as the go down.
Here is an example of what I am trying to achieve in my linearlayout or scrollview (the "fading bottom border".
Thanks for you help!
Subby
You can do that by using the following attributes in the ScrollView.
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="20dp"
If you want it on devices before API14, you need to use the following:
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="20dp"
NOTE: This is actually discouraged as it is seen to have a negative performance impact on devices.
At the bottom of your layout, you can have a view above the listView, and set Gradient Color for the view, and also make it semitransparent, then you can have the effect you want.
I have a listview with overscroll mode on - (I need it on)
And there is a blue overscroll glow everytime I overscroll
how do I get rid of the overscroll glow ?
EDIT:
I am using a custom listview that streches the overscroll drawable (picture) - the way it should be
however, along with the picture there is a glowing effect which i want to get rid of
see the blue thing above the image?
the image IS the overScrollDrawable - but i want the same thing - without the glow
android:overScrollMode="never"
You just need to set your ListView property fadeEdge to none in your layout xml file and you will not get the shadow blue on OVERSCROLL.
android:fadingEdge="none"
EDIT:
this is now deprecated, you can use android:overScrollMode="never" instead.
In the ListView you can set the drawable when overscrolling on top or bottom. This is usually set to a white/transparent drawable that is animated with fadeIn and fadeOut. To set the glowing to something fully transparent you can write:
ListView listView = ...;
listView.setOverscrollFooter(new ColorDrawable(0));
listView.setOverscrollHeader(new ColorDrawable(0));
This keeps the overscroll itself active, so that you can react on overscrolling events, but the glowing should be gone.
We know that, when we scroll a listview at bottom or top of the list, we will see gradient color of yellow and black. Same thing will happen for ScrollView and HorizontalScrollView also at the edges. I want to disable the color when user scrolling these views.
is it possible to disable that color as we disable scrollbars with property
android:scrollbars="none"
If anybody know the solution please help me.
The yellow-black gradient color is actually appears when you over scroll the scroll views.
It can be eliminated by using below code in XML file of ScrollView or HorizontalScrollView
android:overScrollMode="never"
It will work for android 2.3 and above. I don't for below API levels.
Use android:fadingEdge="none" in <ListView>