Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default action bar elevation

I want to use an elevation in a custom layout element and I want to set in XML the value of that element using the default action bar elevation value. I can't find a way to get it in XML and I'd like to avoid to call getElevation() in code. Any tips?

like image 525
greywolf82 Avatar asked Dec 19 '14 14:12

greywolf82


People also ask

What is default elevation for toolbar?

The default elevation of the action bar is 4dp.

How do I set up a support action bar?

To use the ActionBar utility methods, call the activity's getSupportActionBar() method. This method returns a reference to an appcompat ActionBar object. Once you have that reference, you can call any of the ActionBar methods to adjust the app bar. For example, to hide the app bar, call ActionBar.

How do I customize my action bar?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

What is the difference between action bar and toolbar?

The key differences that distinguish the Toolbar from the ActionBar include: Toolbar is a View included in a layout like any other View. As a regular View , the toolbar is easier to position, animate and control. Multiple distinct Toolbar elements can be defined within a single activity.


2 Answers

Default value is 8dp, create dimen with this value and use on whole project, I got it from sources, but the material design guidelines state the action bar elevation should be 4dp. enter image description here

like image 149
Kirill Shalnov Avatar answered Sep 21 '22 09:09

Kirill Shalnov


The standard elevation of the app bar is 4dp according to material design spec. Here is the link: https://material.io/guidelines/material-design/elevation-shadows.html#elevation-shadows-shadows

like image 31
Adi_28 Avatar answered Sep 21 '22 09:09

Adi_28