我在约束布局的第二个视图上收到“重复属性”的错误,如下所述,如果我将任何其他视图放在第二个位置上也没关系。我遇到了同样的错误。 xml代码如下:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/cardView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_marginTop="2dp"
android:background="@android:drawable/dialog_holo_light_frame"
android:elevation="@dimen/cardview_default_elevation"
app:cardCornerRadius="18dp"
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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp"
android:layout_marginTop="18dp"
android:fontFamily="serif"
android:text="Popcorns"
android:textColor="@android:color/black"
android:textSize="26sp"
android:textStyle="bold"
android:translationZ="2dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
//second view starts from here.
<RatingBar
android:id="@+id/ratingBar"
style="@android:style/Widget.DeviceDefault.Light.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_marginStart="56dp"
android:layout_marginTop="8dp"
android:numStars="5"
android:progressTint="#fdd835"
android:rating="3"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.0"
card_view:layout_editor_absoluteY="39dp"
tools:layout_editor_absoluteY="63dp" />
<TextView
android:id="@+id/textViewWeight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:paddingBottom="8dp"
android:text="280 g"
android:textSize="13sp"
android:translationZ="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/ratingBar" />
<TextView
android:id="@+id/textViewPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="8dp"
android:fontFamily="serif"
android:text="Rs 100"
android:textColor="#FF0000"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.86"
card_view:layout_editor_absoluteX="215dp"
card_view:layout_editor_absoluteY="54dp"
tools:layout_editor_absoluteX="216dp"
tools:layout_editor_absoluteY="56dp" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
这里还有其他观点
</android.support.constraint.ConstraintLayout>