I always forget to define android:orientation
property to LinearLayout
's in my layout-resources. Because of default value of layout's orientation (horizontal) I spent a little of time every time I forget about it.
Is there a way to override default orientation of LinearLayout
(btw, I don't want to use custom view) in whole application?
I am also having same problem of every time writing that same line.
There are two ways you can do it:
- Create CustomLayout which will extend LinearLayout. [which you and me also don't prefer].
- Create Live Template - A cool feature of Android Studio.
As we are creating template for XML, define applicable context as XML Text
Now fill details:
Abbreviation name will be your short name. Description is optional. Fill template text as this:
[you can set height or width as whatever you prefer]
Open any Layout xml file. And in Editor, just write your abbreviation which we set earlier.[you can also list out all available live templates by pressing Ctrl+J]
You will see a hint:
Just click on that, and there you go.
Your template text will be here:
[NOTE: In template text I have used $END$, which means after applying code text, the cursor will be placed at this point. For more Live template variables, please have a look at this link]
For more cool details about Live Templates: LINK
Hope, this will help you. You can also create lots of own Live Templates to make life easier. :)