当前位置:   article > 正文

android 布局圆形_Android约束布局–圆形定位

constraintcircle

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。

Android约束布局 (Android Constraint Layout)

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,我们现在也可以基于角度和半径设置位置。 这称为圆形定位。

循环定位 (Circular Postioning)

A picture is worth a thousands of words:

一幅图片值得一千个单词:

android constraint layout circular positioning

From Google Docs

来自Google文档

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.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/225591?site
推荐阅读
相关标签
  

闽ICP备14008679号