Making the layout look pretty
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:
- Select the
Multiline Text
, and then expand thePadding
attribute. Set theall
option to15sp
. This has made a neat area of space around the outside of the text. - To make a nice space below the
Multiline text
, find and expand theLayout_Margin
attribute and setbottom
to100sp
. - On both
TextView
widgets that are aligned/related to the buttons, set thetextSize
attribute to20sp
, thelayout_gravity
tocenter_vertical
, thelayout_width
tomatch_parent
, and thelayout_weight
to.7
. - On both buttons, set the weight to
.3
. Notice how both buttons now take up exactly.3
of the width and the text.7
of theLinearLayout
, making the whole appearance more pleasing. - On the
RatingBar
, find theLayout_Margin
attribute, and then setleft
andright
to15sp
. - Still with the
RatingBar
and theLayout_Margin
attribute, changetop
to75sp
.
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.
Tip
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 Attributes – a quick summary at the start of Chapter 5, Beautiful Layouts with CardView and ScrollView.
Unfortunately, the buttons don't do anything yet. Let's fix that.