AndroidStudio 找不到布局 [英] AndroidStudio Cannot Find Layout

查看:45
本文介绍了AndroidStudio 找不到布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 AndroidStudio 3.6.2.很多次我尝试创建一个新的片段/活动,创建一个布局 xml 文件,但是当我尝试使用布局时,AS 显示未解析的引用"错误.修复"问题的一种选择是让 AS 为我创建布局文件.当我选择此选项时,文件已创建,但 AS 仍然说它无法解析对刚刚创建的文件的引用.注意:它会找到其他布局文件就好了,所以这似乎不是我导入资源的方式.

Running AndroidStudio 3.6.2. A number of times I try to create a new fragment/activity, create a layout xml file, but when I try to use the layout AS shows an 'Unresolved reference' error. One option to 'fix' the problem is for AS to create the layout file for me. When I select this option the file is created, but AS still says it cannot resolve the reference to the file it just created. NOTE: It will find other layout files just fine, so it doesn't seem to be how I'm importing the resources.

这是一个已知问题吗?

这是我创建的布局文件的内容,以防万一有人觉得有帮助.

Here is the content of the layout file I created, just in case someone finds it helpful.

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <include
        layout="@layout/content_video"
        android:layout_width="4dp"
        android:layout_height="2dp" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        android:layout_margin="16dp"
        android:orientation="horizontal">


        <ImageButton
            android:id="@+id/switchVideoCamera"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_switch_camera_white_24dp" />

        <ImageButton
            android:id="@+id/display_video"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_videocam_white_24dp" />

        <ImageButton
            android:id="@+id/mute_audio"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_mic_white_24dp" />

        <ImageButton
            android:id="@+id/connectActionFab"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@android:drawable/stat_sys_phone_call" />

    </LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

推荐答案

我面临同样的问题.我只是用无效的缓存重新启动 Android Studio,它对我有用.

I am facing the same problem. I just Restart Android studio with invalidate Cache and it's work for me.

但是当我使用 Android studio 3.6 的稳定版本时,它非常适合我.

But when I use the stable version for Android studio 3.6 it perfectly works for me.

这篇关于AndroidStudio 找不到布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆