Reputation: 835
I've run my program on Android 2.3 and Android 4.1 but pictures of my app shown very tiny in android 4.1:
I remove <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14" />
in manifest.xml
and my app work perfectly on both:
but I dont want to remove <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14" />
Where is my problem?
abstract of my code is:
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);
...
}
...
}
Upvotes: 5
Views: 157
Reputation: 835
Thanks alot friends
I edited <use-sdk ... />
to
<uses-sdk android:minSdkVersion="1" android:targetSdkVersion="1" />
and added @SuppressLint("NewApi")
to above of MapCanvas
my problem solved!
Upvotes: 0
Reputation: 152847
Removing targetSdkVersion
makes it implicitly 1
, enabling all backwards compatibility modes, including UI scaling for apps targeting below API level 4. That explains why removing the uses-sdk
"fixes" the problem.
To fix your code, you will have to scale your pixel sizes and measures with screen density.
Upvotes: 4