重新打开选项卡时,Android Studio布局引用失效

时间:2022-09-13 20:53:00

On Android Studio 3.0 I have a layout.xml resource for a layout. Its dimensions, text/hint and other attributes aren't hard coded (like having android:width="2dp", but instead all referencing dim.xml and strings.xml - as it is advised on google.developers (like android:width="@dim/width".

在Android Studio 3.0上,我有一个布局的layout.xml资源。它的尺寸,文本/提示和其他属性不是硬编码的(比如有android:width =“2dp”,而是所有引用dim.xml和strings.xml - 因为它建议在google.developers上(如android:width = “@暗淡/宽度”。

However, every time I either reopen Android Studio or the respective layout.xml tab my @dim/dimensions or @strings/strings references disappear and give room to the originals 2dp or text respectively. Then I have to hover and click each of those items to the reference suggestion. If the tab is closed and reopened I need to do everything again...

但是,每次我重新打开Android Studio或相应的layout.xml选项卡时,我的@dim / dimensions或@ strings / strings引用都会消失,并分别为原件2dp或文本留出空间。然后我必须将鼠标悬停并单击每个项目以参考建议。如果标签关闭并重新打开,我需要再做一切......

Is this a bug from the IDE, and is there any way to solve this?

这是IDE的错误,有什么方法可以解决这个问题吗?

2 个解决方案

#1


2  

That's a feature of Android Studio, but you can turn it off. It's not actually replacing your resource references with hardcoded values; it's showing you what the resources actually map to.

这是Android Studio的一项功能,但您可以将其关闭。它实际上并没有用硬编码值替换您的资源引用;它向您展示了资源实际映射到的内容。

To turn it off, uncheck this option (Editor > General > Code Folding > Android String References):

要关闭它,请取消选中此选项(编辑器>常规>代码折叠> Android字符串参考):

重新打开选项卡时,Android Studio布局引用失效

#2


0  

Android Studio shows the values of these references and the color is gray by default but these actually are references, you don't need to worry about that.^_^ just like this: reference

Android Studio显示这些引用的值,默认情况下颜色为灰色,但这些实际上是引用,您不必担心。^ _ ^就像这样:引用

#1


2  

That's a feature of Android Studio, but you can turn it off. It's not actually replacing your resource references with hardcoded values; it's showing you what the resources actually map to.

这是Android Studio的一项功能,但您可以将其关闭。它实际上并没有用硬编码值替换您的资源引用;它向您展示了资源实际映射到的内容。

To turn it off, uncheck this option (Editor > General > Code Folding > Android String References):

要关闭它,请取消选中此选项(编辑器>常规>代码折叠> Android字符串参考):

重新打开选项卡时,Android Studio布局引用失效

#2


0  

Android Studio shows the values of these references and the color is gray by default but these actually are references, you don't need to worry about that.^_^ just like this: reference

Android Studio显示这些引用的值,默认情况下颜色为灰色,但这些实际上是引用,您不必担心。^ _ ^就像这样:引用