约束布局中的屏障错误

时间:2019-02-26 11:20:56

标签: android android-studio android-layout android-constraintlayout

我在android studio中使用了屏障助手。即使设置了所有引用并且还设置了障碍物的方向,该障碍物也不会在布局屏幕中显示,这是一个错误。请帮助我。ScreenShot of The Problem

代码在这里

    <?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/imageViewHeader"
        android:layout_width="0dp"
        android:layout_height="232dp"
        android:contentDescription="@null"
        app:layout_constraintDimensionRatio="16:9"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/header" />

这是障碍的海报视图参考

    <ImageView
        android:id="@+id/imageViewPoster"
        android:layout_width="0dp"
        android:layout_height="150dp"
        android:layout_marginTop="8dp"
        android:contentDescription="@null"
        app:layout_constraintBottom_toBottomOf="@+id/imageViewHeader"
        app:layout_constraintDimensionRatio="w,2:3"
        app:layout_constraintStart_toStartOf="@+id/guidelinePoster"
        app:layout_constraintTop_toBottomOf="@+id/imageViewHeader"
        app:layout_constraintVertical_bias="0.594"
        app:srcCompat="@drawable/poster" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelinePoster"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="8dp" />



    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="8dp"
        android:text="@string/beauty_and_the_beast"
        android:textAppearance="@style/TextAppearance.AppCompat.Title"
        app:layout_constraintEnd_toStartOf="@+id/imageButton"
        app:layout_constraintStart_toEndOf="@+id/imageViewPoster"
        app:layout_constraintTop_toBottomOf="@+id/imageViewHeader" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="8dp" />

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:background="?attr/selectableItemBackground"
        android:contentDescription="@string/bookmark"
        app:layout_constraintEnd_toStartOf="@+id/guideline2"
        app:layout_constraintTop_toBottomOf="@+id/imageViewHeader"
        app:srcCompat="@drawable/ic_bookmark"
        tools:srcCompat="@drawable/ic_bookmark" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:text="March 2017 | PG | 123 minutes"
        android:textAppearance="@style/TextAppearance.AppCompat.Caption"
        app:layout_constraintStart_toEndOf="@+id/imageViewPoster"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

    <Button
        android:id="@+id/button"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:text="Rent From R29.99"
        app:layout_constraintEnd_toStartOf="@+id/button2"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="@+id/guidelinePoster"
        app:layout_constraintTop_toTopOf="@id/barrier3" />

    <Button
        android:id="@+id/button2"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:text="Buy From R129.99"
        app:layout_constraintEnd_toStartOf="@+id/guideline2"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/button"
        app:layout_constraintTop_toTopOf="@id/barrier3" />

//这是障碍

    <android.support.constraint.Barrier
        android:id="@+id/barrier3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="imageViewPoster"
        tools:layout_editor_absoluteX="411dp"
        tools:layout_editor_absoluteY="731dp" />


</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案