ConstraintLayout v1.1.0:能否通过布局编辑器而非XML添加Circular约束?
Great question! Let's break this down clearly:
- Short answer: No, you can't add circular positioning constraints via the layout editor in ConstraintLayout v1.1.0. This feature was only available through manual XML configuration when v1.1.0 launched.
When the circular constraint feature was introduced in v1.1.0, the Android Studio Layout Editor hadn't been updated to support visual configuration for it yet. The team prioritized rolling out the core XML functionality first, and the visual tooling caught up in later releases (specifically starting around ConstraintLayout 2.0 and matching Android Studio versions).
To set up circular positioning in v1.1.0, you'll need to add these three attributes directly to your view in XML:
app:layout_constraintCircle: The ID of the view you want to position relative to (e.g.,@id/center_view)app:layout_constraintCircleRadius: The distance from the center view (e.g.,100dp)app:layout_constraintCircleAngle: The angle (in degrees; 0 points right, 90 points top, 180 points left, etc.)
Here's a practical example:
<TextView android:id="@+id/circular_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Circular Positioned View" app:layout_constraintCircle="@+id/center_anchor_view" app:layout_constraintCircleRadius="120dp" app:layout_constraintCircleAngle="45"/>
If you prefer using a visual interface for this, you'll need to upgrade to a newer version of ConstraintLayout (2.0+) and the corresponding Android Studio release—where circular constraint options are available in the layout editor's constraint panel.
内容的提问来源于stack exchange,提问作者Mohammad Tabbara

