android - 将 ConstraintLayout 更新到 1.1.0 后的 Android UI 问题
问题描述
将 ConstraintLayout 更新到 1.1.0 后,布局仅显示白色背景。它在约束布局中工作正常:1.0.2'。请检查我的 XML。在约束布局:1.0.2' 中它显示结果。在 1.1.0 中仅显示大纲卡视图。请参阅我的 XML 了解更多详细信息。我想更新我的 ConstraintLayout
-->
<android.support.v7.widget.CardView 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:id="@+id/mCardviewPropertytype"
android:layout_width="160dp"
tools:background="@color/gray_black"
android:layout_height="180dp"
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="160dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_margin="8dp">
<android.support.constraint.ConstraintLayout
android:id="@+id/ImgPropertySelect"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/half_circle"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
tools:visibility="visible"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerInParent="true"
app:srcCompat="@drawable/ic_done_white_" />
</android.support.constraint.ConstraintLayout>
<!-- <ImageView
android:id="@+id/ImgPropertySelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/selection_curve"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />-->
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<ImageView
tools:visibility="visible"
android:id="@+id/imageViewPropertyType"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/residential_villa_img"
android:layout_marginLeft="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintLeft_toRightOf="parent"
/>
<TextView
tools:text="@string/nearResidentialArea"
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textColor="@color/gray_black"
android:textSize="20dp"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
解决方案
问题是为什么布局在 1.0.2 下工作。您在 1.1.0 下看到的是布局的真正定义方式。有几个约束将图像和文本移出布局并产生您看到的空白区域。我对以下 XML 进行了更正,看起来一切正常。(我更改了使用的颜色和可绘制对象,因为我无法访问您使用的内容,但您可以轻松地将它们改回来。)
<android.support.v7.widget.CardView
android:id="@+id/mCardviewPropertytype"
android:layout_width="160dp"
tools:background="@android:color/darker_gray"
android:layout_height="180dp"
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="160dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_margin="8dp">
<android.support.constraint.ConstraintLayout
android:id="@+id/ImgPropertySelect"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@mipmap/ic_launcher"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
tools:visibility="visible"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerInParent="true"
app:srcCompat="@mipmap/ic_launcher" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<ImageView
tools:visibility="visible"
android:id="@+id/imageViewPropertyType"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@mipmap/ic_launcher"
android:layout_marginLeft="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintLeft_toLeftOf="parent"
/>
<TextView
tools:text="Near residential area"
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textColor="@android:color/darker_gray"
android:textSize="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
推荐阅读
- https - 带有端口 8443 的 WHM https 抛出警告
- c# - Linq.Select() 中的嵌套表达式方法调用
- r - R Plot 条形图转置数据框
- android - 如果未选择列表视图中的项目,如何更改列表视图中的背景颜色
- javascript - Microsoft Edge window.getSelection() 返回不正确的结果
- angular5 - 如何将当前位置的“纬度”和“经度”设置为“AgmCoreModule”
- python - 使用 python 将加速度计传感器的 x、y、z 值输出为 csv 格式
- java - 初始化后回收站列表适配器为空
- vtiger - Vtiger 7.1 活动目录
- node.js - mongodb:将上一个管道结果的数组引用到下一个管道中