【问题标题】:Android's ConstraintLayout - anchor a view to 2 guidelinesAndroid 的 ConstraintLayout - 将视图锚定到 2 个准则
【发布时间】:2016-11-08 16:27:54
【问题描述】:

使用ConstraintLayout,我正在尝试将视图锚定到 2 guidelines,正如您在所附屏幕截图中的蓝图中看到的那样。

然而,视图被放置在屏幕的左上角,而不是受到两条准则的约束。
知道为什么会这样吗?

谢谢!

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">


    <TextView
        android:layout_width="98dp"
        android:layout_height="17dp"
        android:background="#FAFA00"
        app:layout_constraintTop_toTopOf="@+id/guideline"
        app:layout_constraintRight_toLeftOf="@+id/guideline2"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginTop="64dp"/>

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline"
        android:orientation="horizontal"
        tools:layout_editor_absoluteY="247dp"
        tools:layout_editor_absoluteX="0dp"
        app:layout_constraintGuide_end="576dp"/>

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline2"
        android:orientation="vertical"
        tools:layout_editor_absoluteY="0dp"
        tools:layout_editor_absoluteX="422dp"
        app:layout_constraintGuide_end="178dp"/>

</android.support.constraint.ConstraintLayout>

【问题讨论】:

标签: android android-constraintlayout


【解决方案1】:

在 beta4 中修复了一个与指南相关的错误 -- 尝试更新,它应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 2021-07-26
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多