Ripple Selector Cut Off At Parent Background - android

When you use the background android:background="?android:attr/selectableItemBackgroundBorderless" it gives a nice circle ripple background. At https://developer.android.com/training/material/animations.html it says that It will be drawn upon, and bounded by, the nearest parent of the view with a non-null background.
How do you get around this? I know there must be a way because while using the standard ActionBar, it worked fine. When I used the compat Toolbar, it didn't work anymore and gets cut off. If you take off the colored background from the toolbar it works fine, but I want a colored toolbar...Does anyone know how to use the Toolbar class and still have the rippled selector be unbounded?
As a note I am asking about this for the Toolbar, but I have a few other places where I also need to do the same thing (I use a pull up bar like Play Music has that needs have unbounded buttons as well). So while a work-around for the Toolbar would be nice, it would be nice to have a generic solution as well. Also note that I am NOT talking about the problem described in Ripple effect on Toolbar cut off. I am talking about the selector being cutoff at the bounds of the parent, not cutoff at the button's bounds.

Related

How to cover a view's foreground programmatically with a transculent color

I want to cover views foregrounds with a translucent CustomSeekBar programmatically while it has this foreground:
android:foreground="?attr/selectableItemBackground"
Because of my layouts are very complicated and there are lots of views to cover with a transculent color, I dont want to put my CustomSeekBar to each layout so many times and make them visible.
I want to have the ripple effect still after covering foreground.
It will raise from below of view like that:
Note :
I have my CustomSeekBar.
The covering with translucent color means solution can be
1. setting a translucent color as foreground (but probably I will lose ripple effect)
2. inflating and putting a prepared view (CustomSeekBar) to each view I want. (I dont know how to do it)
I dont know how to do that.
Thanks in advance..

ripple effect with background color in navigation drawer

I have an application with a navigation drawer in it. The layout of the drawer has a specific background color, but the items in it need to have another color. So i added an adapter to fill the list items into the navigationdrawer with another background, what works like a charm. Next I wanted to add a ripple effect to the list items if they get clicked. I read that it's possible to use the following lines to add a ripple effect and a background color.
android:background="#color/navigation_drawer_main_bg"
android:foreground="?attr/selectableItemBackground"
This works fine on my test device with Android 7.1.2 (background is right and ripple effect is there, yay), but on my devixe with Android 5.1.1 there is no ripple effect. Does anyone know a fast solution how the get the ripple effect to my lower api devices without loosing my background color?
Thanks in advance.
Found a solution for me:
add RelativeLayout with background color
add RelativeLayout with android:background="?attr/selectableItemBackground"
insert content from listitem into inner relative layout
Solution: NavigationDrawer ListItem has background color and ripple effect, yay.

What is scrim in collapsibletoolbarlayout?

I read collapsible toolbar layout on developers android. There is a term scrim used there. What is it?
Scrim: A thing that conceals or obscures something.
As per Android CollapsingToolbarLayout:
Content scrim: A full-bleed scrim which is show or hidden when the scroll position has hit a certain threshold. You can change this via setContentScrim(Drawable).
You can use drawable as a scrim on top of the CollapsingToolbarLayouts content when it has been scrolled sufficiently off screen.
app:contentScrim="YOUR_TOOLBAR_COLOR"
Status bar scrim: A scrim which is show or hidden behind the status bar when the scroll position has hit a certain threshold. You can change this via setStatusBarScrim(Drawable). This only works on LOLLIPOP devices when we set to fit system windows.
You can use drawable as a scrim for the status bar content when the CollapsingToolbarLayout has been scrolled sufficiently off screen.
app:statusBarScrim="YOUR_STATUSBAR_COLOR"
Hope this will help!
Here's what the material design docs say:
https://material.io/design/environment/surfaces.html#attributes
Scrims are temporary treatments that can be applied to Material surfaces for the purpose of making content on a surface less prominent. They help direct user attention to other parts of the screen, away from the surface receiving a scrim.
Scrims can be applied in a variety of ways, including:
Darkening or lightening the surface and its content
Reducing the opacity of the surface and its content
Multiple surfaces on a screen at a time can display scrims. Scrims can appear at any elevation, whether in the foreground or background.

Android Toolbar buttons shadow

I added this translucent gradient background to a Toolbar so buttons are noticeable on any background, but I wonder how to make a shadow just under the button itself instead of what I did?
Thank You
EDIT
So I realized the easiest way to achieve that is by setting a Drawable Resources.
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_home);
and
<style name="AppTheme" parent="parent_theme">
<item name="actionModeShareDrawable">#drawable/ic_share</item>
</style>
I downloaded Material Vector assets, added shadow in Adobe Illustrator, imported it to PNG. But the Android Studio's Image Asset/Action Bar and Tab Icons mess up with it I didn't get why - it removed the shadow and colors went different even with Custom 'Theme' so I did different dpi image sizes by myself and that's what I got. That's quite what I wanted
http://imgur.com/vnR98H5
Well, I don't know how to do it with simple button, if you could change Button with FloatingActionButton you may use elevation for making a shadow.
Floating Action Button (FAB) is simply a circle button with some drop shadow that unbelieveably could change the world of design. No
surprise why it becomes a signature of Material Design. So let's start
with this thing. Add FAB in layout file with FloatingActionButton and wrap it with FrameLayout since it needs some parent to make it aligned at bottom right position of the screen.
and
The shadow depth is automatically set to the best practices one, 6dp
at idle state and 12dp at pressed state. Anyway you are allowed to
override these values by defining app:elevation for idle state's
shadow depth and app:pressedTranslationZ for press state's.
From: http://inthecheesefactory.com/blog/android-design-support-library-codelab/en
Of course, you can customize by adding your icon. I'm pretty sure, that play icon as you have on button is in Material Design library.
You can also grab it here: https://design.google.com/icons/
To resume, I advice you learn something more about FloatingActionButton, which alows you to add some nice effect like elevation/shadow and others good things from Material library.
Hope it make your development easier and your app more beautiful.

Change the truck color of a listview in android

I'm not sure if it's called the truck in the world of java, but I've always referred to the scroll bar size thing as a truck. That bit on the right that gets smaller as there are more items in the list, and that stays relative to the current scroll position. Truck? Right?
Well regardless of what it's called, does anyone know how to change it from white to another color. I've a list with green text in it, and in fact all my controls are green on a black background. It looks quite spunky and fun. But for the "truck"; it remains white.
Does anyone know how to change the truck color?
Just do
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
and let scrollbar_vertical_thumb be a gradient
refer to this

Categories

Resources