Android Toolbar buttons shadow - android

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.

Related

Ripple Selector Cut Off At Parent Background

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.

Android ActionBar on Lollipop not styling correctly

I am designing an app with Material Design, but I am having trouble styling the ActionBar.
First of all, I can not get the ActionBar to render a shadow. I have tried setting the elevation in multiple ways:
In the styles.xml (v21):
<item name="android:elevation">4dp</item>
<item name="elevation">4dp</item>
In the onCreate() method
getActionBar().setElevation(4);
However, none of these result in the ActionBar rendering a shadow. Not sure if this is important, but I am running Android 5.0.1 Lollipop. What am I missing in trying to render a shadow? I don't really want to make a drawable shadow and set it as the window background.
Secondly, my ActionBar buttons are square, and when I click on them, the ripple is cut off in a square, while in other apps I have used the mask for the ripples has been circular, and my app had been using round buttons, but recently it changed and I don't know why. Could I have accidentaly changed something making them square?
Thank you
The issue is that u use ActionBar while the other apps use ToolBar. Read about and change your code, everything should work after that.

Android toolbar icons style

I'm working on an app which has two activites. The second activity has a back button which provide back navigation.
The problem I have is that the back navigation button takes the background from the toolbar no matter if the toolbar has the "style=" attribute or the "app:theme=".
Here is the toolbar with the "style=" attribute:
http://postimg.org/image/f57zaap4p/
http://postimg.org/image/3u5blxi9l/
An here is the toolbar with the "app:theme=" attribute:
htt.p://postimg.org/image/kkqxgo8d1/
htt.p://postimg.org/image/ofpq5i251/
(Please remove the point from "htt.p" from the last two links - I can't post more than two links)
I want the icons to have a white background. I would appreciate if you can help!
You can style the action overflow button in your styles.xml adding this line:
<item name="android:actionBarItemBackground">...</item>
You can set it as a #drawable or a #color resource. I suggest you to define a selector to manage, e.g, the background color as the icon is pressed.
As for the back arrow, this is, to me, quite an open question. You could take a look at my own question here , where you can also find a selector sample.
Basically you can override the arrow/burger background with
<item name="android:selectableItemBackground">...</item>
but (I fear) it acts as a background for a lot of widgets you might have. In facts, this also overrides actionBarItemBackground, so if you want to use both, the latter is enough.

Should I hide the android actionbar or try to style it

I am building an app for Android and iOS. It is working but the creative people want to totally change the style so that the top part of the screen (where the actionbar is on android) is taller and has their logo centered in it.
Should I hide the actionbar and put the logo (and custom nav icons) at the top of my layouts, OR should I try to change the style of the actionbar (make it taller and include the logo in the center)? Either option seems a bit painful, but I don't think I can talk them out of it.
you should create own View. You can't center any item (icon, logo, title) in ActionBar, also you can't change height. Android ACtionBar's guidelines are very strict. You might change some params by using "findViewById" and passing hardcoded android ids, but they might change for different device manufacturers resulting no change on these units (or even some crashes)
Personally, I would probably modify the ActionBar and try to maintain as much of the functionality as possible. Especially if this is a long running project and it might go back to the standard action bar later.
You can do this by adding your own custom view that will contain your centered logo to the action bar:
getActionBar().setDisplayShowCustomEnabled(true);
getActionBar().setCustomView(R.layout.action_bar_view);
You can then use the action buttons and home/up buttons as you normally would.
Depending on your needs however, you may find it challenging to keep the logo centered since the home and action buttons will add to the left and right respectively which will shift the center view if unbalanced. If so, you can still use your custom action bar view from above and add buttons directly to it inside a FrameLayout to maintain the centering.
To change the height, you can use themes and styles. Wherever you define your styles, set the actionBarStyle and the height in that style:
<style name="MainTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle">
<item name="android:height">70dp</item>
</style>

How to make the instagram actionbar style for android?

I know how to make the gradient and the logo. But I don`t know how to add all that different borders and how to add the refresh icon (that also has some custom border around it).
Instagram Action Bar:
How is that possible?
You can do it by using a horizontal LinearLayout with 2 children, the left hand column with the logo and the right hand column with the refresh button. You can create a background drawable using the Shape XML:
http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
I'd look at the provided ActionBar and ActionBarCompat. It has hooks for producing basic, as well as complex action bars.

Categories

Resources