3. Widgets and Layouts are
used to construct a UI.
• A Widget is a UI element, like a text field or button
• Layouts are invisible containers, like LinearLayout or
RelativeLayout
14. Need to override onDraw
to be able to show
something.
• 2D graphics
• Text in different variations
• Other components
• Or pretty much anything else
37. Sets of properties that specifies the
look of a Widget. This can be
properties such a width, height and
colors. The concept is similar to
CSS and separates presentation
from the content.
40. Goes into
res/values/attrs.xml
• Declared in the top <resources or in the <declare-stylable>
element
• The <attr> element has two attributes name and format
– Name is used when referring from code e.g.
R.stylable.PriceView_amountText
– Format defines the value it represents
• Reference
• Color
• String
• Boolean
• And a few more
43. A problem with styles is
that it's hard to change
the style of an View
that's included within a
compound component.
And we can't change the
style in runtime.
44. Themes, a style that’s
applied to a whole
Activity or Application
• With custom attributes we can provide a way to
style views within compound components
• Makes it easier for others to override default styles
• This can be hooks for styles, dimensions, colors...
46. How do we make a custom
component available for
other applications.
• We can't use JAR
• We don't want to copy-paste resources
47. Library Projects
• Holds shared code and resources
• Resources are merged at build time
• Can be used for
– Custom components
– White label apps
– Paid and free versions of the same app