- Mastering Android Studio 3
- Kyle Mew
- 273字
- 2021-07-02 18:42:36
Controlling position with bias
Bias can be best understood here as a percentage value, but rather than position the view according to its center or a corner, it is the percentage of space either side of it. So if the bias towards the top is 33%, then the margin below will be twice the size of the one below it.
Setting bias is even easier than understanding it, as once a constraint is set on any opposing sides of a view, an associated slider will appear in the Properties graphic Properties editor:

A quick glance at the generated code shows the format for this attribute as follows:
app:layout_constraintHorizontal_bias="0.33"
The value of using bias to position screen elements lies partly in the simplistic approach, but its true value comes when it comes to developing for multiple screens. There are so many models available and they all seem to have slightly different proportions. This can make design layouts that look fantastic on all of them, very time consuming and even shapes as similar as 720 x 1280 and 768 x 1280 can produce undesirable results when tested with the same layout. The use of the bias attribute goes a long way to solving these issues, and we shall see more of this later when we take a look at layout previews and the percent library.
As if all this didn't make designing a layout easy enough, constraint layouts have two other extremely handy functions that almost automate UI design: auto-connect and inference.
- Oracle從入門到精通(第3版)
- 深入淺出Prometheus:原理、應用、源碼與拓展詳解
- Production Ready OpenStack:Recipes for Successful Environments
- Learning Laravel 4 Application Development
- QGIS:Becoming a GIS Power User
- 精通Python設計模式(第2版)
- C++面向對象程序設計習題解答與上機指導(第三版)
- Learning OpenStack Networking(Neutron)
- 51單片機C語言開發(fā)教程
- 現代C++編程實戰(zhàn):132個核心技巧示例(原書第2版)
- 代替VBA!用Python輕松實現Excel編程
- JavaScript機器人編程指南
- Learning Splunk Web Framework
- PHP+MySQL動態(tài)網站開發(fā)從入門到精通(視頻教學版)
- Building Business Websites with Squarespace 7(Second Edition)