In this section, we will explore some more attributes that control the finer details of our UI. You have probably noticed how the UI looks a bit squashed in some places and wonky and unsymmetrical in others. As we progress through the book, we will continually add to our repertoire to improve our layouts, but these short steps will introduce and take care of some of the basics:
Multiline Text,
and then expand the Padding
attribute. Set the all
option to 15sp
. This has made a neat area of space around the outside of the text.Multiline text,
find and expand the Layout_Margin
attribute and set bottom
to 100sp
.TextView that are aligned/related to the buttons,
set the textSize
attribute to 20sp, the layout_gravity
to center_vertical,
the layout_width
to match_parent,
and the layout_weight
to .7.
.3
. Notice how both buttons now take up exactly .3
of the width and the text .7
of the LinearLayout,
making the whole appearance more pleasing. RatingBar,
find the Layout_Margin
attribute and then set left
and right
to 15sp
.RatingBar
and the Layout_Margin
attribute, change top
to 75sp
.You can now run the app and see our first full layout in all its glory:
Notice that you can play with the RatingBar
, although the rating won't persist when the app is turned off.
By way of a reader challenge, find an attribute or two that could further improve the appearance of the LoadConstraintLayout
and LoadTableLayout
text. They look a little bit close to the edges of the screen. Refer to the section on attribute summary at the start of the next chapter for suggestions.
Unfortunately, the buttons don't do anything yet. Let's fix that.
3.17.110.58