小编Adn*_*YAS的帖子

Android Studio 3.1.3,设计视图始终为空

我是Android开发的新手,我的Android Studio 3.1.3演示项目或我创建的任何项目都有这个问题.

即使我可以在我的设计视图(ConstraintLayout)上拖放不同的控件但在设计视图中没有显示任何控件,它会显示一段时间然后消失.

我可以在activity_main.xml文本选项卡,组件树甚至运行模式中看到我拖放的所有元素,但是在设计选项卡中没有显示,设计视图中没有显示任何元素,它总是空白,甚至没有hello world show.

我尝试了无效缓存重启,重启我的电脑,更改放大 - 进出,推断约束,但没有运气.控制

除非我在设计视图中看到东西,否则我做不了多少.

空设计视图:

空设计视图

运行模式视图

运行模式视图

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:text="Button" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="20dp" />

    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CheckBox"
        tools:layout_editor_absoluteX="154dp"
        tools:layout_editor_absoluteY="181dp" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.libra.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

的build.gradle …

android android-layout android-studio

21
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

android-layout ×1

android-studio ×1