0
votes

Is it possible to set a project default for width and height of ALL xml views? 80% of items in my xmls have:

android:layout_width="match_parent"

android:layout_height="wrap_content"

Why not set that as the default and only specify where it is different. Would that be possible?

2
These are the mandatory attributes to any view in xml So any which way you have to set these both to your view SO what's the point of setting them as default at all? - B.shruti
because im am typing the width and height 100 times where they are the same... - bluevoid

2 Answers

0
votes

One way to achieve this is to define the two attributes in a style and apply that style to all your xml's. But I really don't see any point of doing that, both layout height and width are mandatory attributes that need to be provided either directly or indirectly through a style.

-1
votes

Because the different devices such as Samsung Galaxy J1, Galaxy J2, Sony Xperia XA, Xperia Utra, Galaxy Note 7 ... have different width, height and resolution ... If we set

android:layout_width="50dp"

or

android:layout_width="50px"

we can not ensure that the app will full match with the sreen phone. Besides, some app can rotate vertical and horizonal