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?
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.
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
The default elevation of the action bar is 4dp. I did a little experiment by creating one custom view right below the action bar and set its elevation to 4dp. So, both were looking the same. Official documentation also mentioned 4dp standard elevation for the action bar.
Nav drawer: 16dp
App bar: 4dp
Card: 1dp to 8dp
FAB: 6dp
Button: 2dp to 8dp
Dialog: 24dp
Here App bar refers to Action bar.
Reference: Elevation
Here is the official resource available for the elevations.
The default elevation of AppBarLayout is #dimen/design_appbar_elevation (which is 4dp). Actionbar has #dimen/abc_action_bar_elevation_material as default elevation (which is 4dp as well).
These values can be found in stateListAnimator of Widget.Design.AppBarLayout and the parent of Widget.AppCompat.ActionBar respectively. The Toolbar doesn't seem to have any default elevation.
Related
In XML we have material3 bottom navigation bar style. It's color achieved by using surface color with elevation = 3dp. So in XML higher elevation means lighter background color.
I'm trying to implement same behavior in Compose. But it looks like elevation in Compose doesn't change bottom navigation's color but only adding shadow. So can we apply same behavior in Compose somehow or the only way is to add separate bottom nav's color in Color.kt?
BottomNavigation(
modifier = Modifier.heightIn(80.dp),
backgroundColor = MaterialTheme.colorScheme.surface,
elevation = 3.dp
)
You are probably not using material3 library but the old one. There is no BottomNavigation composable in material3, it's called NavigationBar and it has tonalElevation argument instead of elevation that does what you want.
I want my menu items on the BottomNavigationBar to have text-only labels with no icon. Unfortunately, it looks like design_bottom_navigation_item.xml always has a 24x24dp space reserved for the icon, with no publicly-exposed way to set it to gone. And even after getting past that, the label layout is set to a layout_gravity of bottom|center_horizontal, and it doesn't look like there's a way to programatically set layout_gravity to centered.
What is the fastest, easiest way to achieve the goal of a text-only menu item on the bottom nav bar? I'm thinking I can do this by creating a custom version of the item layout, then subclassing BottomNavigationItemView, BottomNavigationMenuView, and BottomNavigationView to specify that custom layout... but that seems like an awful lot of work for one little change. Am I missing something simpler?
dont put iandroid:icon property to your item
Just use the code below. I tried hard to do this easy way but failed.Then I made an alternative. Just use transparent color instead of icon drawble
<item
android:icon="#android:color/transparent"
android:id="#+id/navigation_id"
android:title="title" />
Add this in your dimens file. Then you can add padding according to your navigation view size.
<dimen name="design_bottom_navigation_height"tools:override="true">30dp</dimen>
I want to change Floating Action button shadow colour from black/grey to colorprimary/custom color of shadow ** shadow example like below image with **center blue FAB button with light blue shadow not grey shadow. But we can change the FAB button background color. But as you can see in image there is blue shadow of FAB button.I want to achive that thing.
try this :: app:backgroundTint="#color/colorAccentGrey"
where colorAccentGrey = YourColor
and put xmlns:app="http://schemas.android.com/apk/res-auto" at the beginning of the XML if you forggt,
and for Remove shadow :: app:elevation="0dp"
Hope this will help you.. :)
I think you have 2 options:
as #Uttam said, change the elevation of the FAB widget
to make a custom design and embed it as an image in your layout as shown here http://androidgifts.com/android-material-design-floating-action-button-tutorial/
None of the answer worked for me. So i worked this. anyhow it will give shadow like effect that enough for me
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_add_black"
app:elevation="0dp" // disable outside shawdow
app:borderWidth="30dp" // make borderwidth to 25dp or height of fab
app:backgroundTint="#00E5FF" // now you will see only this color with shawdow
android:backgroundTint="#00E5FF" // since border is 30dp u ll not see this color and if you want to check reduce border width to 25dp then ull see this color in center as a small dot.
/>
A simple solution is to remove the stroke(border-width), the default value is 0.5dp change it to 0dp, that is
app:borderWidth="0dp"
Refer Regular and mini FAB key properties in Material Design documentation!
Link - https://material.io/components/buttons-floating-action-button/android
How do I change the size of the <item> elements inside a Navigation Drawer element?
No matter what the icons always seem to resize automatically to 24dp like this:
I need to increase the size of the icons to 34 dps but the <item> elements don't seem to have any attribute to change this setting in the XML:
Thanks.
You can change the size of navigationView icon by overriding design_navigation_icon_size attribute. You can put it in dimens and because you're overriding a private attribute, you need to include tools:override="true"
<dimen name="design_navigation_icon_size" tools:override="true">40dp</dimen>
copy this in your Navigation drawer xml.
app:itemTextAppearance="#style/TextAppearance.AppCompat.Display1"
there are many text appearence to choose from.
NavigationView implements the material design specs for a navigation drawer. Therefore the size of the icons are fixed at 24dp. You'd have to build your own navigation drawer to break the material design specs if you want 34dp icons.
I have a TabWidget and I'm trying to style the divider. (See image above)
I set the Divider Drawable of the TabWidget but the top & bottom part is unchanged. I can't figure out how to style it.
All you need to do is set the dividerPadding attribute to 0dp in your TabWidget.
android:dividerPadding="0dp"
Also, maybe consider switching to ActionBar.Tabs instead, just considering TabWidget is deprecated.
It seems that Holo theme has default 16 pixels dividerPadding for each TabWidget.
I try to set it to zero in the XML but it is not working.
Fortunately, it works for me to set it dynamically as below
myTabHost.getTabWidget().setDividerPadding(0);
Note: I am using android.support.v4.app.FragmentTabHost
are you talking about grey bars on the top and the bottom of the divider? use fill_parent for the drawable's height and width if that is the case!