1
resposta

Ao colocar cardView e a constraintLayout perde as referencias das constraint.

Boa noite professores alguém pode me ajudar já estou a 1 semana tentando resolver isso e da erro sobre o cardView fia igual no video do professor mais estou usando a versão do android studio 4.0.1.

Quando eu coloco o card view jogo as view dentro cardview depois coloco outra constraintLayout perde toda a referencia por favor me ajudem vou colocar o código.

insira seu código aqui

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools">


<androidx.cardview.widget.CardView
    android:id="@+id/item_pacote_cardview"
    android:layout_width="0dp"
    android:layout_height="300dp"
    app:layout_constraintBottom_toTopOf="@+id/item_pacote_imagem"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />

<ImageView android:id="@+id/item_pacote_imagem"
    android:layout_width="0dp"
    android:layout_height="100dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0"

    tools:src="@sample/pacotes.json/pacotes/imagem"

    android:scaleType="centerCrop"/>

<TextView android:id="@+id/item_pacote_local"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"


    tools:text="@sample/pacotes.json/pacotes/local"

    app:layout_constraintStart_toStartOf="@+id/item_pacote_imagem"
    app:layout_constraintEnd_toEndOf="@+id/item_pacote_imagem"
    app:layout_constraintTop_toTopOf="@+id/item_pacote_imagem"
    app:layout_constraintBottom_toBottomOf="@+id/item_pacote_imagem"
    app:layout_constraintVertical_bias="1.0"
    app:layout_constraintHorizontal_bias="0.0"
    android:textSize="14sp"
    android:layout_margin="8dp"
    android:padding="8dp"
    android:textStyle="bold"
    android:textColor="@android:color/white"
    android:background="@android:drawable/screen_background_dark_transparent"/>

 <View android:id="@+id/item_pacote_divisor"
     android:layout_width="0dp"
     android:layout_height="3dp"
     android:background="@android:color/holo_orange_dark"
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintEnd_toEndOf="parent"
     app:layout_constraintTop_toBottomOf="@id/item_pacote_imagem" />

<TextView android:id="@+id/item_pacote_dias"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    tools:text="@sample/pacotes.json/pacotes/dias"

    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@id/item_pacote_divisor"
    android:layout_margin="8dp"
    app:layout_constraintHorizontal_bias="0.0"
    android:textSize="16sp"
    android:textStyle="bold"/>

<TextView android:id="@+id/item_pacote_preco"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"


    tools:text="@sample/pacotes.json/pacotes/preco"

    android:textSize="20sp"
    android:textColor="@android:color/holo_green_dark"
    app:layout_constraintTop_toBottomOf="@+id/item_pacote_dias"
    app:layout_constraintStart_toStartOf="@+id/item_pacote_dias"/>

</androidx.constraintlayout.widget.ConstraintLayout>

1 resposta

Vanderlei, tudo bem ?

O correto seria você fazer algo assim:

<cardview>
    <constraint>
        <-- views>
    </>
</>