Android View - manipulate the shadow - android

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.

Related

Adding boundary shadows to RecyclerView [duplicate]

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

How does Android do its spinner style with the triangle icon in the corner?

I've spent way too much time researching this, but I'm wondering if anyone can provide any insight to how Android does its spinner styling with the triangle dropdown indicator?
The reason I want to know is that I am using a custom textview as spinner item, and once I use that I lose the triangle. In addition, I want to make the triangle white.
I've seen previous answers with modifying the theme but I don't want all spinners to change so I don't want to modify the entire theme. I want to learn how Android does the triangle so I can recreate it. I tried using a list-layout drawable with a triangle shape but I'm wondering if there is a better way?
You can set drawbleEnd
android:drawableEnd="#drawable/imgresource"
create an image of how you want as your spinners background with whatever type or triangle and whichever color your want and then set that image as the background of your textview like this
android:background="#drawable/myBackground"
It a simple Nine Patch Drawable.
You can create a NinePatch graphic, set a black dot on the top and left to expand the top and left edges. With a triangle in the bottom right.

How do you get ripple effect to extend past view bounds?

The touch ripple effect here expands past its bounds. How is this done?
EDIT: I am okay with this working on 5.0+ only.
I've read from a few places that:
If you want to apply the standard ripple effect on Android 5.0: API 21
or more, which should not be limited to your view (unbounded ripple),
just apply to your View background :
android:background="?android:attr/selectableItemBackgroundBorderless"
I have tested it, what is happening here is that the ripple is not on the buttons, but on the background object. So the ripple is not actually extending past the buttons bounds here, but rather extending to the bounds of the background wrapper card object.
To replicate what you see in the picture,
1. Make a new layout. I would use either a relative layout or linearlayout
2. Add the upper EditText ("Add a quick note"), and then and the four lower buttons, all with clear backgrounds, but with gray borders like above.
3. Set your ripple animation on the background of the layout you put the buttons in, and be sure to set android:clickable="true"on your layout!
That gave me the same effect as your picture.
doc already mentioned it
//An unbounded red ripple.
<ripple android:color="#ffff0000" />
https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html

Changing the color of the spinner

In this picture you can see (barely lol) that the spinner icons that rest on the bottom and bottom right are very hard to see due to the black background that I am using. What would I need to do to make that greyish looking color to white or any color for that matter?
Try this tutorial:
Android Custom Spinners
A similar process is used for working with custom buttons and other elements.
Updated as the link is broken. Try this stackoverflow answer
Spinner Background Design

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);

Categories

Resources