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.
Related
Like the picture, I set a dark green color, but the light green background appears.
This is the only thing I've set up.
Button's background was set to the colorPrimary of the theme.
So when I changed Button to Image Button, it came out right.
As a result of the test, it seems that the problem is occurring in material design 1.2.1 or higher.
I have to use Theme.MaterialComponents.Light.NoActionBar, so I can't change Theme.
This is a known issue in material design, and found solution adding app:backgroundTint.
The primary color of my application is white and hence my navigation bar color is also white. My problem is that navigation bar buttons are also white in color. How do I make sure that buttons are visible in white background. The app theme I have used is Theme.AppCompat.Light.DarkActionBar.
I have tried using different theme but none seem to be working so far.
Can anyone tell me how I could resolve this issue?
For Android Oreo and above you can try this:
View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_NAVIGATION.
You can also refer here for more details: https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
Also there is another approach:
you can achieve it by placing this in your theme:
<item name="android:windowLightNavigationBar">true</item>
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.
Maybe this is not quite an ActionBar problem but the problem is as follows;
I have an EditText and when you long click on the EditText, text selection options appear on ActionBar's position by default. My problem is that, both the texts and background are white, so they cannot be read. Here is the screenshot:
I tried some possible causes of the problem but nothing helped. For example, I tried to change the theme
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
However, any theme with the AppCompat results totally white.
Also I changed the project theme in Android Studio's interface as follows:
However it's still white.
The copy-paste options are there and you can click on them, but how can I make them appear? Another solution on SA suggested manually replacing gray icons. But I believe this is not the usual case in Android and there should be another way. Any ideas?
Ohoy. As Im upgrading my app to L, I replaced ActionBars with Toolbars and whenever I start an ActionMode now it pushes down all the content. (I suppose this is because the ActionBar is once again shown in order to display the ActionMode.) Is it possible to display the ActionMode as an overlay, or have it reside within the Toolbar?
Also no styling options seem to apply to it, which makes me wonder whether theres a new way to style it. Any ideas?
Im using AppCompat V7 21 and so far Ive tried windowActionModeOverlay=true and toolbar.startActionMode(..)
Use <item name="windowActionModeOverlay">true</item> in your app theme (without android:).