1

Is using dimension as even number recommended or does it improve performance?

For example:

android:layout_width="22dp" 

Over

android:layout_height="21dp" 

Material design guideline too has more even numbered dps and sps than odd numbered.

1
  • "or does it improve performance?" If it did improve performance then Google would've told you that. Since they didn't, I don't think it improves performance. Commented Mar 25, 2019 at 12:22

2 Answers 2

3

Setting dimension as even number does not affect performance but it is recommended in google material design to use for even spacing. , For example, - if all of your spacing are a multiple of 8 dp you follow the material design.

Another good example of Google material design is the aspect ratio - the there are recommended aspect ratios for your UI :

The following aspect ratios are recommended for use across your UI: 16:9, 3:2, 4:3, 1:1, 3:4, and 2:3

But, if you can avoid using fixed sizes on your views and use constraintLayout instead this would be the best option for you.

why is that you ask? - because different devices having a different screen size and when you put fixed size on some view your layout may not be responsive to all screen sizes.

Sign up to request clarification or add additional context in comments.

Comments

0

It does not have to do anything with performance.

I am always trying to follow 8, 16, 32 size values. Also size like 32-8 also counts. Don't think that it is good practice to use side padding 15dp instead 16dp or 25dp when you can use 24dp. But there is always exceptions depending on design.

1 Comment

given how similar they are, you should edit your existing answer instead of posting a new one, even if it has a downvote.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.