我有一个尺寸为300 * 90的按钮图形.Hdpi / mdpi / ldpi的尺寸必须如何?谢谢
答案 0 :(得分:61)
Google suggests使用
3 : 4 : 6 : 8 : 12 : 16
缩放比例
ldpi : mdpi : hdpi : xhdpi : xxhdpi : xxxhdpi
。例如:
在您的示例中,如果提到的按钮大小适用于hdpi,则正确的尺寸应为:
答案 1 :(得分:5)
这取决于您设计该图形的设备屏幕大小。如果您希望它在320x480(HVGA)画布上显示为300x90,那么您的像素尺寸对于MDPI设备是正确的,您需要以下图像:
LDPI是MDPI扩展的75%,HDPI是MDPI扩展的150%。例如,如果您在480x800(WVGA)画布上设计了这些图形尺寸,那么HDPI的尺寸已经正确,您需要从那里缩小其他两个尺寸:
希望有帮助!
答案 2 :(得分:1)
完成公式以创建所有资产文件夹图像
首先,您必须决定要为哪个DPI创建图像,一旦决定并创建了图像,请按照Google Guide Lines
使用以下代码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
答案 3 :(得分:0)
为此,您可以尝试我的工具,该工具用于缩放不同类型的图像(单个或批量)(png,jpg,gif,svg,psd,9-patch ..)。使用hiqh质量缩放算法并支持某些无损压缩工具,如pngcrush。有一个GUI和命令行ui。