Adding boundary shadows to RecyclerView [duplicate] - android

If I look at the stackoverflow app's horizontal recyclerview, I can see that they use the "fading edge" technique so that the user will know that there are items on the left and right of the recyclerview and he / she can scroll.
In listview, I think this effect is enabled by calling the below as described by Romain Guy (http://www.curious-creature.com/category/android/page/2/):
android:cacheColorHint="#00000000"
No such option exist in Recyclerview unfort. Is there a built in method to allow for these fading edges for recyclerview or will it just have to be a hack?

I think the attribute you are looking for is:
android:requiresFadingEdge="horizontal|vertical"
you can search and better understand this attribute from the recycler view's documentation.
The other attribute you are talking about, 'cacheColorHint', can be used to match the fading color with that of your background. This attribute is the color upon which the list view is drawn, and is defined as an opaque color, because you don't always have a white background (which I think is the default color... but I'm not sure), the best option is to use a transparent color, "#00000000", as suggested by Romain Guy.
Hopefully this is what you are looking for!
Cheers

Related

How to make UI shadow to any view

thank you for answering me
I just want to know how i can make the shadow below this card
I already tried several ways like Elevation... but it didn't work for me.
I searched a lot about it and I found that website :
Shadow generator
But i'm wondering if there is another way, using xml or anything else.
You are half right in that elevation is required for a shadow effect.But note this is only applicable to view that are not buttons. For buttonViews you can add a statelist animator that handles the properties of a button for all its states.Also if you are using something like a textView that does not have any margins you might as well use a background to show the shadow as follows:
android:elevation="30dp"
android:background="#000"
For other views, this means simply adding the elevation attribute as shown above and the background is not required
This link will help:
How to provide shadow to Button

Add a static border to a view that has a dynamic background

I've searched SO for a while but couldn't find an answer to my exact question. I usually found 2 similar problems that do not suit my needs:
Many people asked for how to draw a border around a view, and the solution is often to use a shape with a stroke as the background of the view. But this uses a static background.
I can't use this (or don't know how in my case), because I'm creating a color picker and I draw the background programmatically.
Other people asked how to draw a border programmatically, but that's only a fallback option for me.
One solution obviously came to my mind: wrapping my view with dynamic background in another view with the stroke. But I don't like this one as it unnecessarily complicates the layout, and could have an impact on performance too. I'd rather draw the border programmatically with the background than use nested views.
Hence my question:
Is there a clean (androidic) way to set the border of a view in the XML when the background is set programmatically (without using nested views)?
If not, I guess I'll just go for a dynamic stroke.
You can create your own view which does the same as your current view but with an added border.
I haven't tried this yet so I apologize for the lack of information but I believe this should be possible.

Gmail tablet style scroll bars with transparent actionbar

I've been trying stuff and searching for the last couple of hours and got no where so I thought I'd ask here.
Basically the Honeycomb version of Gmail has a listview on the right for it's message list and when you scroll the listview the items go under the actionbar which appears to have some form of gradient on it with #00FFFFFF at the bottom going up to #FFFFFFFF at the top giving the impression of the items fading out.
But they important thing to notice here is that the SCROLLBAR on the listview never goes underneath the ActionBar! and the default top position for the listview is underneath the scrollbar.
I've tried to implement a similar style layout for my app with a scrollview that scrolls underneath the actionbar which has an alpha set on it, it looks all nice and well but the scrollbars go underneath as well! :( and it makes it look a bit weird, it's not a nice option.
I've achieved what I have so far by using
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
and
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
which is a an XML drawable that simply has a color of #BB000000 (no gradient just yet)
this is the current effect, the scrollbar can be seen underneath the actionbar :(
this is the desired effect with the scrollbar never going into the actionbar but the content does scroll up underneath it
Edit: I think this probably uses something custom in Google and have all but given up figuring it out
call this before super.onCreate(savedInstanceState); in onCreate of your activity
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
More: http://developer.android.com/reference/android/view/Window.html#FEATURE_ACTION_BAR_OVERLAY
I can't see an easy way of doing this but I have come up with two possible solutions. There could well be a much better option that I couldn't see obviously.
The first and easiest, is to create a 9patch background file for you ActionBar that has an expanding gradient area and a fixed opaque area at the right hand side, the same side as your scroll bar. This way the scrollbar would still go under the ActionBar, but it would be hidden. However it would have the affect of the scrollbar disappearing / getting smaller.
Another option would be to edit the scrollbar thumb in the xml like this:
<ListView android:scrollbarThumbVertical="#drawable/YOUR_CUSTOM_THUMB" ></ListView>
Then create a scrollbar thumb with a transparent offset at the top.
Thinking about it I think the second option is probably the best to go for and will give you the best result. I realise it's a pretty crappy hack. Looking into a code way of doing it, I think you would have to extend a number of classes and override a load of methods.
simply use:
getActionBar().setBackgroundDrawable(null);

Android View - manipulate the shadow

In a listview or many of the scrollable views, there are on top and buttom a shading effect.
I am not talking about the fading effect: It is the black color that appears on the top along with the fading effect.
Actually even if i am not scrolling seems like this black color will stay! please check the image
How can this effect be removed? (maybe manipulate the color or sth)
http://img28.imageshack.us/img28/4035/badtl.png
this is a list
thanks
You can manipulate the color of the fading edge with the android:cacheColorHint attribute, if thats what you're talking about and you haven't figured it out in the past 2 months - see This post in the android docs for details.

Changing the ListView shadow color and size

When the list of items in a ListView is longer than the size of the ListView, you'll see a shadow indicating that there are more items above or below. By default, this shadow is black. This is not desirable.
If I set the cacheColorHint to the following:
android:cacheColorHint="#00000000"
The shadow will be transparent, showing the drawable I have set to the layout's background. This is not desirable either.
I wish to simply change the color of the shadow to a lighter shade of black, or perhaps gray. Is there a way to specify this?
Also, is there a way to change the shadow's size?
By android:cacheColorHint="#00000000" you are setting this color to transparent. I don't know which color you want to use exactly, but try android:cacheColorHint="#FF777777". I think it must work.
I wouldn't delete your question yet, you still had the remaining question of how to change the size. :)
You can use the method setFadingEdgeLength(int length) to do this; it's directly inherited from View, so just about any View should be able to use it.

Categories

Resources