开发者

Multiple screens for HTC Desire and HTC Sensation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 5 years ago.

开发者_如何学Go Improve this question

The thing I want to do is to have different layout for the Sensation and Desire models.

I read things about programming for multiple screens and providing resources for different screen size and density, but this sensation resolutions drive me crazy . I have a layout that works perfectly on HTC Desire; they are placed in the layout and the drawings are placed in hdpi. Everything is working perfectly. The problem comes when I try to run the app on the Sensation, everything is misplaced and looks very ugly.

My question is where to put the Sensation layouts ? What qualifier name should I use for Sensation?


Try finding the resolution and the density of the device (Sensation) using the following code.

    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);

    int width = display.getWidth();
    int height = display.getHeight();
    int density = dm.densityDpi;
    String densityString = null;

    if(density == DisplayMetrics.DENSITY_HIGH) {
        densityString = "HDPI";
    } else if(density == DisplayMetrics.DENSITY_MEDIUM) {
        densityString = "MDPI";
    } else if(density == DisplayMetrics.DENSITY_LOW) {
        densityString = "LDPI";
    }

Then use you appropriate resource name qualifiers for the drawable and layout folders as in Multiple Screen Support. (e.g.) drawable-large-hdpi, layout-large-hdpi

This is not feasible all the times, since you won't have access to all the devices out there. So it's better to create AVDs with different display configurations based on the table depicted in How to Test Your Application on Multiple Screens from the above given link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜