简体   繁体   English

应用程序不适合android虚拟设备

[英]application not fit to the android virtual device

In my android application, I have a problem that when I run my application, its not fit to the emulator and some part cut on it like below: 在我的android应用程序中,我遇到一个问题,当我运行我的应用程序时,它不适合仿真器,并且某些部分切成如下所示:

在此处输入图片说明

And also you can see below I have a button also on it like below image: 而且您还可以在下面看到我也有一个按钮,如下图所示:

在此处输入图片说明

But its not show me the full image, means a button is missing on the emulator. 但是它没有显示完整的图像,这意味着模拟器上没有按钮。

How can I resolve it. 我该如何解决。 kindly suggest me, waiting for reply. 请建议我,等待回复。

Thanks 谢谢

Basically, your designer and emulator are using different screen dimensions. 基本上,您的设计师和仿真器使用的是不同的屏幕尺寸。

You can change the designer to use the same screen dimensions. 您可以更改设计器以使用相同的屏幕尺寸。 Currently, from your screen shot you're using the Nexus One layout. 目前,根据屏幕截图,您正在使用Nexus One布局。 From what I can tell the emulator doesn't look like the Nexus One screen dimensions. 据我所知,模拟器看起来不像Nexus One屏幕尺寸。

With Android it isn't as simple as 1 layout for all dimensions, screen sizes and devices. 使用Android时,所有尺寸,屏幕尺寸和设备的布局都不像1布局那么简单。 You have to implement multi-screen support to address this. 您必须实现多屏支持才能解决此问题。 You can usually do this by having a variance on dimensions, styles and layouts. 通常,您可以通过在尺寸,样式和布局上有所不同来实现此目的。 A lot of the time one layout will work universally, but dimensions often need tweaking. 很多时候,一种布局可以普遍使用,但是尺寸常常需要调整。

See http://developer.android.com/guide/practices/screens_support.html for more on Supporting Multiple Screens. 有关支持多屏的更多信息,请参见http://developer.android.com/guide/practices/screens_support.html

It is a problem that can occur in real devices (remember, we have loads and loads of different screen sizes for android) so you definitely need to fix it. 这是在实际设备中可能发生的问题(请记住,我们为Android设备加载的负载和加载的屏幕尺寸不同),因此您绝对需要修复它。

The best way to avoid this is to wrap the entire layout inside a ScrollView , so the user can scroll to see all the content of your layout. 避免这种情况的最佳方法是将整个布局包装在ScrollView ,以便用户可以滚动查看布局的所有内容。

If you are trying to fit all the elements on the screen then you need to account for different screen sizes and densities. 如果要适合屏幕上的所有元素,则需要考虑不同的屏幕尺寸和密度。 In your particular case you are building the screen on a different sized screen than the emulator. 在特定情况下,您正在将屏幕构建在与模拟器不同的屏幕上。

Assuming you do not want the screen to scroll (which is solved using a ScrollView), then to fix this, you can do the following: 假设您不希望屏幕滚动(使用ScrollView解决),然后要解决此问题,可以执行以下操作:

  1. Build different XML layouts for different screen sizes 针对不同的屏幕尺寸构建不同的XML布局

  2. Use dimen files to specify different sizes for some or all elements on the screen so that they re-size depending on the screen size. 使用dimen文件为屏幕上的某些或所有元素指定不同的大小,以便它们根据屏幕大小重新调整大小。

  3. Use weighted LinearLayout so that Android re-sizes the elements according to the screen they are placed on. 使用加权的LinearLayout,以便Android根据放置元素的屏幕来调整其大小。

Each of these is pretty easy to search and find various ways of doing. 这些中的每一个都非常容易搜索和找到各种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM