gpt4 book ai didi

android - Android 4.1 中的不同输出

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:46:05 24 4
gpt4 key购买 nike

我已经在 Android 2.3 和 Android 4.1 上运行我的程序,但我的应用程序的图片在 android 4.1 中显示得非常小:

enter image description here

我删除了 <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14" />manifest.xml我的应用程序在两者上都能完美运行:

enter image description here

但我不想删除 <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“修复”了问题。

要修复您的代码,您必须 scale your pixel sizes and measures with screen density .

关于android - Android 4.1 中的不同输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21232965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com