Eclipse 和 Android XML 布局给出了“‘默认’不是任何设备/语言环境组合的最佳匹配”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3774686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:08:26  来源:igfitidea点击:

Eclipse and Android XML layouts gives "'default' is not a best match for any device/locale combination"

androideclipseeclipse-adt

提问by Neil Traft

This is my first time making an app with XML layouts. In the past I have always dynamically generated my layouts at runtime, so don't worry, I am NOT an Android newbie. Still, this is my first time with static layouts. So what's this message all about?

这是我第一次使用 XML 布局制作应用程序。过去我总是在运行时动态生成布局,所以别担心,我不是 Android 新手。尽管如此,这是我第一次使用静态布局。那么这条消息是关于什么的呢?

[2010-09-22 20:43:23 - Rockport] 'default' is not a best match for any device/locale combination.
[2010-09-22 20:43:23 - Rockport] Displaying it with 'Locale Language ___Region __, Normal Screen, Short screen aspect ratio, Landscape Orientation, No Dock, Day time, Medium Density, Finger-based touchscreen, Soft keyboard, Qwerty keybard, Trackball navigation, Screen resolution 480x320'

[2010-09-22 20:43:23 - Rockport] 'default' is not a best match for any device/locale combination.
[2010-09-22 20:43:23 - Rockport] Displaying it with 'Locale Language ___Region __, Normal Screen, Short screen aspect ratio, Landscape Orientation, No Dock, Day time, Medium Density, Finger-based touchscreen, Soft keyboard, Qwerty keybard, Trackball navigation, Screen resolution 480x320'

It gets printed to my Eclipse console every time I open up one of the layouts in the layout/folder. If I open the layout from any other folder, such as layout-land/then I get no message. Is it just the graphical layout editor saying, "Here's how I'm going to display things for you?" Can I safely ignore it?

每次我打开layout/文件夹中的一个布局时,它都会打印到我的 Eclipse 控制台。如果我从任何其他文件夹打开布局,layout-land/那么我就不会收到任何消息。是否只是图形布局编辑器在说:“我将如何为您显示内容?” 我可以安全地忽略它吗?

采纳答案by user492822

No don't ignore it, it does mean something.

不,不要忽视它,它确实意味着什么。

What it is saying is that Eclipse has found a layout which it believes is more accurate and is switching to it.

它的意思是 Eclipse 已经找到了一种它认为更准确的布局并正在转向它。

So for example if you have a default layout and a low density layout, it will switch to the low density layout. Any changes you make to the layout will be in the low density code not in the default code.

例如,如果您有默认布局和低密度布局,它将切换到低密度布局。您对布局所做的任何更改都将在低密度代码中而不是在默认代码中。

I don't know how to switch back, which is getting very annoying, apart from closing the xml and opening up the correct one.

我不知道如何切换回来,这很烦人,除了关闭 xml 并打开正确的 xml 之外。

If anyone knows how to switch, and yes I have tried changing the settings at the top of the editor between low density and medium density devices, please tell me. Thanks.

如果有人知道如何切换,是的,我曾尝试在低密度和中密度设备之间更改编辑器顶部的设置,请告诉我。谢谢。

回答by Romel Hdez

Do not run the project with the file XML selected. Clean build the project, Only click in the project name, after select run, you won't have this error

不要在选择了 XML 文件的情况下运行项目。clean build工程,只在工程名里面点一下,选择run后就不会出现这个错误了

回答by Morteza

I had this problem and for me just solved by selecting my projects "MainActivity" from dropdown menu "Associated activity or fragment providing context" in the graphical view of my layout.

我遇到了这个问题,对我来说只是通过从布局的图形视图中的下拉菜单“相关活动或片段提供上下文”中选择我的项目“MainActivity”来解决。