赞
踩
android 布局圆形
In this tutorial, we’ll be discussing a cool attribute present in Constraint Layout, namely circular positioning. We’ll be developing a custom clock UI in our Android Application using the same.
在本教程中,我们将讨论约束布局中存在的一个很酷的属性,即圆形定位。 我们将使用相同的方法在Android应用程序中开发自定义时钟UI。
We’ve discussed Constraint Layout in this tutorial.
我们已经在本教程中讨论了约束布局。
It’s a great layout and provides lots of points to set views relative to one another.
这是一个很棒的布局,并提供了许多要点来设置相对于彼此的视图。
With the introduction of ConstraintLayout 1.1, we can now set positions based on angles and radius too. This is termed as circular positioning.
通过引入ConstraintLayout 1.1,我们现在也可以基于角度和半径设置位置。 这称为圆形定位。
A picture is worth a thousands of words:
一幅图片值得一千个单词:
Circular Positioning consists of the following three attributes that need to be defined in the ConstraintLayout child views:
循环定位包含以下三个属性,这些属性需要在ConstraintLayout子视图中定义:
layout_constraintCircle
: This would be defined in the View B. It would be set to the id of A. layout_constraintCircle
:这将在视图B中定义。它将设置为A的ID。 layout_constraintCircleRadius
: The distance between the center of the two views. layout_constraintCircleRadius
:两个视图的中心之间的距离。 layout_constraintCircleAngle
: The angle defines the circular position of B with respect to A. This is set in degrees( 0 to 360). An angle of 0 means the view B is vertically above A. layout_constraintCircleAngle
:角度定义B相对于A的圆形位置。以度(0到360)设置。 角度为0表示视图B垂直于A。 We can create a complete circle with views positioned at different angles.
我们可以创建一个完整的圆,并以不同角度放置视图。
In the following section, we’ll create a custom clock in which TextViews would be circularly positioned around an ImageView.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。