English 中文(简体)
了解屏幕分辨率
原标题:android problem in getting the screen resolution size
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
Log.e("FirstImage", "Width = "+width+"Height = "+height);

以上是我用来显示屏幕尺寸的代码,但问题在于我正在读到width=3<20/code>和hels=569<>。 但是,我正在使用带有屏幕尺寸的摩托拉里程碑(<>编码>480x854)。

我如何能够找到正确的规模?

最佳回答

http://realmike.org/blog/2010/12/21/multiple-screen-sizes-with-processing-for-android/

以上链接拥有丰富的资源,可以说明屏幕分辨率和如何获得真正的屏幕分辨率等。

问题回答

如果你不支持大型屏幕,那么你就会失去这种恐慌,因为屏幕往往较小,无法显示照片(这本来就是不支持你的大屏幕)。

如果你在你的发言中加上这一点,就会显示正确的价值观。

     <supports-screens 
        android:largeScreens="true" 
        android:smallScreens="true" 
        android:normalScreens="true" 
     /> 

你们甚至可能希望与你们一道发挥作用。

 android:anyDensity

归责,但我并不认为需要解决你目前的问题。

审判

WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
int height = d.getHeight();

The <supports- Screens> tag should fin work. See See See

rel=“nofollow”http://developer.android.com/guide/topics/mani/supports- Screens-element.html

一个重要问题是,为什么你不相信你从显示台调机中重新获得的规模? 如果你们要做这样的事情的话。

canvas.drawRect(new Rect(0,0,width,height), new Paint());

Your rectangle would certainly fill the screen. There s a scaling happening, but maybe you don t care.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...