For the More Curious: New Developments in ConstraintLayout

ConstraintLayout has additional capabilities to help arrange its child views. In this chapter you positioned views by constraining them to the parent as well as to other, sibling views. ConstraintLayout also includes helper views, such as Guidelines, that simplify arranging views on the screen.

Guidelines do not display on the app screen; they are just a tool to help you position views the way you need. There are both horizontal and vertical guidelines, and they can be placed at a specific location on the screen using dp values or by setting them to be a percentage of the screen. Other views can be constrained to the guideline to ensure that they appear at the same location, even if the screen size is different.

Figure 10.35 shows an example of using a vertical Guideline. It is positioned at 20 percent of the width of the parent. Both the crime title and date have a left constraint to the Guideline instead of to the parent.

Figure 10.35  Using a Guideline

Using a Guideline

MotionLayout is an extension of ConstraintLayout that simplifies adding animations to your views. To use MotionLayout, you create a MotionScene file that describes how the animations should be performed and which views map to each other in the starting and ending layouts. You can also set Keyframes that provide intermediary views in the animation. MotionLayout can animate from the starting view through the various keyframes you provide, then ensure that the view animates to the ending layout appropriately.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.168.172