我使用约束布局 (android.support.constraint.ConstraintLayout
) 作为我的 XML 文件中的主要布局。当我们得到布局的两个 View 时(一个用于用户 View ,第二个用于拖放 View 并提供它们之间的关系)。但我只得到一个完全空白的窗口,如下所示:-
在我的布局中使用任何 View 时出现此错误。请检查下图
我的布局文件如下:-
<?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/