我在Android 2.3和Android 4.1上运行我的程序,但我的应用程序的图片在android 4.1中显示得非常小:
我删除< uses-sdk android:minSdkVersion =“5”android:targetSdkVersion =“14”/>在manifest.xml中
我的应用程序完美地适用于:
但我不想删除< uses-sdk android:minSdkVersion =“5”android:targetSdkVersion =“14”/>
我的问题在哪里?
public class MapCanvas extends ImageView
{
...
public MapCanvas(Context context)
{
super(context);
}
public MapCanvas(MainActivity context,Bundle state)
{
super(context);
this.context = context;
...
}
...
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
...
//Paint Offset X,Y,Zoom
this.paint.setColor(Color.rgb(51,51,51));
this.paint.setFakeBoldText(true);
this.paint.setTextSize(15);
String text = "X:" + OFFSET_X + ",Y:" + OFFSET_Y + ",Zoom:" + MapZoom.Zoom;
canvas.drawText(text,5,15,paint);
...
}
...
}
最佳答案
删除targetSdkVersion使其隐式1,启用所有向后兼容模式,包括UI scaling for apps targeting below API level 4.这解释了为什么删除uses-sdk“修复”问题.
原文链接:/android/431002.html要修复您的代码,您必须使用scale your pixel sizes and measures with screen density.