When trying to pick padding and width and margin for UI elements, I see that some default values pop up in the XML. This makes me think --> Is there a standard set of measurements that I can use for material design instead of trying to guess what looks right?
Like in the picture below, where specifically in the documentation can i find the list of all dimensions available?
Android specifies certain widths and heights that you should use for your application. For example the horizontal and vertical activity margins, the padding in TextView or EditText. See https://material.google.com/layout/metrics-keylines.html for the guidelines.
Related
In the UI design of a screen, I have a very big text (180 sp). To follow the design though I need to have just a 16 dp padding around the text, including the inner vertical padding of the text. The problem is that even if I put a padding of 0 dp the inner padding is already bigger than 16 dp
Is there a way to set to 0 the inner vertical padding of a Text with Jetpack Compose?
Actually that is innate, it follows material guidelines. If you wish to disable it, an alternative would be to look at the source of Text. You could just copy the source and make modifications to meet your requirements. It is doable, and is a recommended practice to customize behavior for your needs.
I have a TabLayout which it's height is 50dp. each tab inside it contains both icon and title inside itself. But as this article says If I use both icon and title inside a tab, TabLayout height should be 72dp. now my question is :
if I set 50dp for my TabLayout's height, Will go out my design from Material Design? Thanks
sorry about my English.
All sizes mentioned in Material.io are required to respect Material Design Guideline.
Well, Material Design is just a set of guidelines based on some research. It suggests good practices and consistent solutions. Material Design guidelines used to be pretty strict, for example when it comes to shapes of buttons, because they wanted to make users used to some concepts. With Material Design 2 the guidelines relaxed a lot.
Minimal size is meant to keep items distinguishable and accessible, but still not too big. I wouldn't make tabs much smaller, because it may look squashed. It won't affect the usability though as minimal size for clickable items is 40dp, I guess. You would probably need to reduce spacings and sizes of other items in your app in order to make it look consistent with shorter tabs.
Changing font is fine as long as it was designed for on-screen reading. The size can be any as well as long as text is large enough to be readable.
If your design is consistent, items are distinguishable, easy to use and aligned well, then you're good. Take a look at Material Studies on material.io - these designs show how far you can go without breaking anything.
I am trying to immitate the search interface shown in the first image in this documentation on the specification about the Search pattern in Material Design.
But I can not find any information on how much distance is there between the SearchView and the edge of the Activity's frame, i.e. the padding applied to the root layout of the Activity.
How do I know for sure how much padding should I apply to root layout of the Activity, in accordance with Material design specification?
What I have tried:
In this specification of Metrics and Keylines, particularly in this image, they have shown a paddingLeft of 16dp, but the padding applied in the following picture doesn't seem to have 16dp, and neither does Google Now app, actually this padding, that is the one applied in the following picture is nothing more than like 8dp.
Whilst not strictly Material Design specific, the #dimen/activity_vertical_margin is commonly defined as 16dp within Android applications.
This is commonly used across many applications and the design guidelines.
It should be noted that the horizontal margin does differ over screen sizes according to the Material Design guidelines.
res/values/dimens.xml usually specifies:
<dimen name="activity_horizontal_margin">16dp</dimen>
Whilst you will commonly see res/values-w820dp/dimens.xml for tablet devices specify:
<dimen name="activity_horizontal_margin">64dp</dimen>
I'm developing an android calendar app so I need to align the days in a grid-like style. I'm using the API Level 8 so I need to align them by margins. But when switching to Bigger screens the numbers get to the left of screen and do not cover the whole screen.(I know that is because I use dp as a unit for my margin-left). Is there something like CSS % (percent) in Android Layouts?
Try this
android:layout_weight="1"
on each element in that section. It should space evenly.
It's weight attribute for views inside LinearLayout. Here is a good explanation what it means. But you can use it only to set view sizes, not margins. However you can put your view into RelativeLayout, place this layouts to take all available screen width and set attribute centerInParent=true in your view.
I try to implement a good reusable color picker for my Sketcher application. Instructions and screenshots are here: http://bit.ly/sketcherapp
The problem is I'm stuck with a good "resizable" UI which enable me to support wide range of devices with different screen sizes.
The top two widgets should be the same height and have proportional widths: 80 to 20. Also it would be nice to specify paddings in XML.
Current implementation is not good. I hardcoded some values into code and also it looks bad on Xoom devices because of inaccurate layout measurements.
Is there any way to implement this behavior? Ideally, I need some way to do it like with HTML tables (pseudocode):
table.width=100%, td1.width=80%, td2.padding=5px, ...
or something like that.
Current implementation:
code:
https://github.com/wargoth/Sketcher/tree/master/src/org/sketcher/colorpicker
layout:
https://github.com/wargoth/Sketcher/blob/master/res/layout/color_picker.xml
Thank you.
The top two widgets should be the same height and have proportional widths: 80 to 20.
Use a horizontal LinearLayout, android:layout_width="0dip" for both widgets, and android:layout_weight="80" and android:layout_weight="20", respectively.
Also it would be nice to specify paddings in XML.
Use android:paddingLeft and kin.
OK. I stopped boring with it and created dedicated layouts for each screen size.