android - 约束布局在布局文件中不可见......并且在膨胀任何 View 时出现错误

标签 android android-constraintlayout constraint-layout-chains

我使用约束布局 (android.support.constraint.ConstraintLayout) 作为我的 XML 文件中的主要布局。当我们得到布局的两个 View 时(一个用于用户 View ,第二个用于拖放 View 并提供它们之间的关系)。但我只得到一个完全空白的窗口,如下所示:- enter image description here

在我的布局中使用任何 View 时出现此错误。请检查下图

enter image description here

我的布局文件如下:-

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/constraintLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout_editor_absoluteY="25dp"
    tools:layout_editor_absoluteX="0dp">

    <ImageView
        android:id="@+id/image_shot"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        tools:layout_editor_absoluteY="0dp"
        tools:layout_editor_absoluteX="0dp" />

</android.support.constraint.ConstraintLayout>

我已经在 SO 上尝试了以下解决方案,但它对我不起作用,请检查我搜索过的链接

1. First Link
2. Second Link
3. Third Link

请帮我解决这个问题。谢谢

最佳答案

尝试从

开始
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/constraintLayout"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>

如果预览未显示,请尝试更改所选设备或检查 gradle implementation 'com.android.support.constraint:constraint-layout:1.0.2'

中的已实现库

关于android - 约束布局在布局文件中不可见......并且在膨胀任何 View 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45082619/

相关文章:

android - 为什么 Media Player 找不到我的 SD 卡的 URI?

android - 智能 watch 2 : failed to show widget and control when compiling apk with Proguard

android - 如何将 DrawerLayout 与 ConstraintLayout 一起使用

androidx.constraintlayout.widget.constraintlayout 没有可以拖动的链

android - ConstraintLayout 左对齐两个水平链的中间元素?

java - findFirstVisibleItemPosition() 在 nestedScrollView 中返回 0

java - 从广播接收器恢复之前的 Activity

android - ConstraintLayout 内的 DrawerLayout

android - 阻止键盘推对齐到底部 View

android - 使用 ConstraintLayout 展开链元素组