English 中文(简体)
hdpi/ldpi/mdpi的图表尺寸
原标题:Graphic dimensions for hdpi/ldpi/mdpi
  • 时间:2011-11-22 19:05:05
  •  标签:
  • android

我有一个图形,尺寸300*90。 h/mdpi/ldpi的尺寸如何? 增 编

最佳回答
问题回答

这取决于对你设计这种图形的大小装置。 如果你想在320x480(HVGA)大豆中显示300x90,那么,你的粉末尺寸对计量吸入器装置是正确的,你需要以下图像:

  • LDPI: 225x68px
  • MDPI: 300x90px
  • HDPI: 450x135px

LDPI是计量吸入器规模的75%,而DPHPI是计量吸入器规模的150%。 例如,如果你在480x800(WVGA)水面设计了这些图象,那么,对于PPI来说,你的范围已经正确,你需要从那里缩小另外两个层次:

  • LDPI: 150x45px
  • MDPI: 200x60px
  • HDPI: 300x90px

Hope that Helps!

Complete Formula to create all asset folder images

首先,你们必须决定,一旦你决定并制作图像,那么,你们会根据

public class DPICalculator {

    private final float LDPI = 120;
    private final float MDPI = 160;
    private final float HDPI = 240;
    private final float XHDPI = 320;

    private final float BASE_DPI = MDPI;

    public static void main(String[] args) {
        DPICalculator cal = new DPICalculator();

        cal.calculateDPI_baseUnitPixel(300, 90, cal.HDPI);
    }

    private float densityWidth;
    private float densityHeight;

    public void calculateDPI_baseUnitPixel(float width, float height, float currentDensity) {

        densityWidth = getDensityPX(width, currentDensity);
        densityHeight = getDensityPX(height, currentDensity);

        this.calculateAllDP();
    }

    private float getDensityPX(float value, float currentDensity) {
        return (value / (currentDensity / BASE_DPI));
    }

    public void calculateDPI_baseUnitDPI(float width, float height, float currentDensity) {

        densityWidth = getDensityDPI(width, currentDensity);
        densityHeight = getDensityDPI(height, currentDensity);

        this.calculateAllDP();
    }

    private float getDensityDPI(float value, float currentDensity) {
        return (value * (currentDensity / BASE_DPI));
    }

    private void calculateAllDP() {
        // get all settings.
        float low_pw = densityWidth * (LDPI / BASE_DPI);
        float low_ph = densityHeight * (LDPI / BASE_DPI);

        float med_pw = densityWidth * (MDPI / BASE_DPI);
        float med_ph = densityHeight * (MDPI / BASE_DPI);

        float high_pw = densityWidth * (HDPI / BASE_DPI);
        float high_ph = densityHeight * (HDPI / BASE_DPI);

        float xhigh_pw = densityWidth * (XHDPI / BASE_DPI);
        float xhigh_ph = densityHeight * (XHDPI / BASE_DPI);

        System.out.println("LDPI " + low_pw + " x " + low_ph);
        System.out.println("MDPI " + med_pw + " x " + med_ph);
        System.out.println("HDPI " + high_pw + " x " + high_ph);
        System.out.println("XHDPI " + xhigh_pw + " x " + xhigh_ph);

    }
}

成果

LDPI 150.0 x 45.0
MDPI 200.0 x 60.0
HDPI 300.0 x 90.0
XHDPI 400.0 x 120.0




相关问题
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 ...

热门标签