我在包含 Relativelayout 的 Cardview 中编辑 RelativeLayout 时搞砸了!ConstraintLayout 会将相对布局的 wrap_content 更改为 0 并添加工具:layout_editor_absoluteX="10dp" 相对布局内的所有 textview 将折叠 cardview 的右上角!(嵌套 CardView 中的元素与 CardView 之外的元素对齐)
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="357dp"
android:layout_height="114dp"
android:layout_margin="5dp"
app:cardCornerRadius="2dp"
app:contentPadding="10dp"
app:cardElevation="10dp"
tools:layout_editor_absoluteY="36dp"
app:cardBackgroundColor="@android:color/white"
tools:layout_editor_absoluteX="11dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="10dp"
tools:layout_editor_absoluteY="10dp">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
tools:text="Location"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<ImageView
android:src="@drawable/ic_hotel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView3"
tools:text="Bangalore"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
tools:layout_editor_absoluteX="10dp"
tools:layout_editor_absoluteY="10dp"
android:layout_alignBottom="@+id/imageView3"
android:layout_toRightOf="@+id/textView2"
android:layout_toEndOf="@+id/textView2" />
</android.support.v7.widget.CardView>
任何关于使用 ConstraintLayout 设计 RelativeLayout 的指南都会非常完整,RelativeLayout 在使用 ConstraintLayout 时不能在任何地方使用?当 CardViews 是 ConstraintLayout 的子代时,在使用 RelativeLayout 时使用 CardView 的子代的指导方针是什么?