- Mastering Android Studio 3
- Kyle Mew
- 349字
- 2021-07-02 18:42:36
Graphic Properties tool
You will no doubt have noticed the diagrammatic representation of a view that pops up in the Properties window, when a ConstraintLayout view is selected as follows:

This tool allows size and position properties to be edited with a single click and for the output to be instantly understood in a simple schematic form. It only takes seconds to learn and can speed up interface design considerably, particularly when experimenting with different layouts.
Inside the central square, representing our view, there are four lines, which when clicked on cycle through the following three states:
- Unbroken line: The view is an exact width, for example, 240dp
- Fuzzy line: The view can be any size (dependent on bias), match_parent
- Directed line: The view matches its own content, wrap_content
Often, we will not want to constrain a view to the very edge of its container. For example, we may wish to divide the layout into two or more sections and have views organized within them. Guidelines allow us to divide our screens into sections and can be used exactly like parent edges. Take the following example:

Guidelines like this are most easily added from the constraint toolbar at the top of the design editor. Guidelines are added as XML components and look like this:
<android.support.constraint.Guideline
android:id="@+id/gl_vertical"
android:layout_width="wrap_content"
android:layout_height="311dp"
android:orientation="vertical"
app:layout_constraintGuide_begin="175dp" />
We can now use these guidelines to center elements according to the whole layout or any of the four panes we have created, and all without nesting a single layout. In the following screenshot, we have a centered header and side panel with another view contained in a single pane, and we can of course apply bias to any of these sections:

If this system did not already provide enough advantages, there are more. Firstly, it proves very useful when aligning text as well as a more enhanced positioning technique referred to as bias, which performs a similar function to the weight attribute, but is better when it comes to designing for multiple screens. We will take a look first at text alignment constraints.
- 少兒人工智能趣味入門:Scratch 3.0動(dòng)畫(huà)與游戲編程
- ThinkPHP 5實(shí)戰(zhàn)
- Learn Programming in Python with Cody Jackson
- C++程序設(shè)計(jì)基礎(chǔ)教程
- AppInventor實(shí)踐教程:Android智能應(yīng)用開(kāi)發(fā)前傳
- 數(shù)據(jù)結(jié)構(gòu)案例教程(C/C++版)
- Julia高性能科學(xué)計(jì)算(第2版)
- Terraform:多云、混合云環(huán)境下實(shí)現(xiàn)基礎(chǔ)設(shè)施即代碼(第2版)
- Getting Started with Eclipse Juno
- Mastering C++ Multithreading
- Getting Started with Python
- Node.js區(qū)塊鏈開(kāi)發(fā)
- 算法秘籍
- 百萬(wàn)在線:大型游戲服務(wù)端開(kāi)發(fā)
- Visual C#(學(xué)習(xí)筆記)