If you have a lot of views like this - most likely you would like to move
repetitive code into a single place and just keep a reference to them in the
layout. That’s what we call a style - a reusable set of view attributes.

So far it’s very similar to XMLs, but let’s see how it can be developed further.

Calculated values

Since we have the full power of a real programming language - we can describe
dependencies between the values. For example if our text color is 20% darker
than some common accent color - we can write it as an expression. It also
applies to other values like sizes, margins, weights etc - they may be derived
from some base style.

Now if you want to change you app accent color from blue to red - you only need
to change it in one place.

The style definitions look more compact and they are very flexible - we can even
include certain conditional constraints. For example if we want our view to be
full-screen in landscape and have bigger font - it can be part of the style:

It’s useful if you want to separate how your view looks from how your view
behaves - you may move look-and-feel styles into a utility class, but leave
your data bindings and listeners inside your main class.

As you can see, Anvil is more flexible than XMLs and you may architect your
styles any way you like by using constants, expressions, overriding styles or
mixing them together.