两个小但重要的变化:
> TextView宽度应为0dp,即匹配约束而不匹配父级
>指导方向应垂直而非水平
这是代码:
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.3" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Hello text"
app:layout_constraintLeft_toRightOf="@id/guideline"
app:layout_constraintRight_toRightOf="parent" />
另请注意,我将ConstraintLayout高度更改为match_parent,以便在输出中显示指南.您可以将其更改回wrap_content.