Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Dawn Griffiths, David Griffiths
Using Constraint Layouts in Android Studio
1.
Introducing the constraint layout
You design constraint layouts VISUALLY
Create a new project
Make sure your project includes the Constraint Layout Library
Add the String resources to strings.xml
Change activity_main.xml to use a constraint layout
Using the blueprint tool
Position views using constraints
We’ll add a horizontal constraint to the button
Add a vertical constraint
Changing the view’s margins
Changes to the blueprint are reflected in the XML
How to center views
Adjust a view’s position by updating its bias
How to change a view’s size
1. Make the view a fixed size
2. Make it just big enough
3. Match the view’s constraints
4. Specify the width:height ratio
How to align views
Let’s build a real layout
First, add the top line of views
Get the design editor to infer the constraints
The Infer Constraints feature guesses which constraints to add
Add the next line to the blueprint...
... and then add the button
Finally, add a view for the message
Test drive the app
Want to learn more?
About the Authors
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Using Constraint Layouts in Android Studio
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset