Android Studio无法正确显示xml文件

时间:2018-10-27 12:28:59

标签: java android android-studio

Android Studio突然在xml文件中显示自动生成的代码。我曾尝试使缓存/重新启动无效,但不能解决问题。我也尝试过清理项目并重建它,但是它也不起作用。即使一切都可以在编辑器中正确显示,例如sublime文字。 这是我的android studio显示的xml文件之一的代码。

Code as showing in android studio

Code as shown in sublime text editor

`/ *自动生成的文件。请勿修改。  *  *此类是由  *从找到的资源数据中获取gradle插件。它  *请勿手工修改。  * /

package com.airbnb.lottie;

public final class R {
    private R() {}

    public static final class anim {
        private anim() {}

        public static final int abc_fade_in = 0x7f010000;
        public static final int abc_fade_out = 0x7f010001;
        public static final int abc_grow_fade_in_from_bottom = 0x7f010002;
        public static final int abc_popup_enter = 0x7f010003;
        public static final int abc_popup_exit = 0x7f010004;
        public static final int abc_shrink_fade_out_from_bottom = 0x7f010005;
        public static final int abc_slide_in_bottom = 0x7f010006;
        public static final int abc_slide_in_top = 0x7f010007;
        public static final int abc_slide_out_bottom = 0x7f010008;
        public static final int abc_slide_out_top = 0x7f010009;
    }
    public static final class attr {
        private attr() {}

        public static final int actionBarDivider = 0x7f030000;
        public static final int actionBarItemBackground = 0x7f030001;
        public static final int actionBarPopupTheme = 0x7f030002;
        public static final int actionBarSize = 0x7f030003;
        public static final int actionBarSplitStyle = 0x7f030004;
        public static final int actionBarStyle = 0x7f030005;
        public static final int actionBarTabBarStyle = 0x7f030006;
        public static final int actionBarTabStyle = 0x7f030007;
        public static final int actionBarTabTextStyle = 0x7f030008;
        public static final int actionBarTheme = 0x7f030009;
        public static final int actionBarWidgetTheme = 0x7f03000a;
        public static final int actionButtonStyle = 0x7f03000b;
        public static final int actionDropDownStyle = 0x7f03000c;
        public static final int actionLayout = 0x7f03000d;
        public static final int actionMenuTextAppearance = 0x7f03000e;
        public static final int actionMenuTextColor = 0x7f03000f;
        public static final int actionModeBackground = 0x7f030010;
        public static final int actionModeCloseButtonStyle = 0x7f030011;
        public static final int actionModeCloseDrawable = 0x7f030012;
        public static final int actionModeCopyDrawable = 0x7f030013;
        public static final int actionModeCutDrawable = 0x7f030014;
        public static final int actionModeFindDrawable = 0x7f030015;
        public static final int actionModePasteDrawable = 0x7f030016;
        public static final int actionModePopupWindowStyle = 0x7f030017;
        public static final int actionModeSelectAllDrawable = 0x7f030018;
        public static final int actionModeShareDrawable = 0x7f030019;
        public static final int actionModeSplitBackground = 0x7f03001a;
        public static final int actionModeStyle = 0x7f03001b;
        public static final int actionModeWebSearchDrawable = 0x7f03001c;
        public static final int actionOverflowButtonStyle = 0x7f03001d;
        public static final int actionOverflowMenuStyle = 0x7f03001e;
        public static final int actionProviderClass = 0x7f03001f;
        public static final int actionViewClass = 0x7f030020;
        public static final int activityChooserViewStyle = 0x7f030021;
        public static final int alertDialogButtonGroupStyle = 0x7f030025;
        public static final int alertDialogCenterButtons = 0x7f030026;
        public static final int a`

6 个答案:

答案 0 :(得分:1)

只需将现有项目复制到另一个文件夹,然后使用android studio重新打开该项目,它将再次正常显示。

今天,当我打开一个Java文件时,这个问题发生在我的Android Studio中,向我展示了XML文件。

答案 1 :(得分:1)

如果您没有清除android studio的缓存,请尝试清除它。

C:\Users\user_Name\.AndroidStudio3.5\system\caches

答案 2 :(得分:0)

布局xml文件或AndroidManifest.xml文件中应该存在错误。 我注意到只有一些文件在波浪线下带有红色,请仔细检查,尤其是其中包含自定义小部件,例如lotteryanimationview

答案 3 :(得分:0)

这一次发生在我身上,我关闭了android studio,打开了相同项目文件夹(IDE,git GUI)的所有其他文件,然后又再次打开了,xml文件按预期显示。

希望这会有所帮助。

答案 4 :(得分:0)

这对我有用。首先关闭Android Studio。

然后转到

C:\ Users \您的用户名\ .AndroidStudio3.5 \ system \缓存

删除缓存文件夹。

并打开android studio。现在您的项目已打开,没有任何问题。

答案 5 :(得分:0)

有时候,当android studio长时间工作时,会发生这种情况。重新打开该项目可能会对您有所帮助。