Android shortcut bitmap launcher icon size

前端 未结 3 1262
感情败类
感情败类 2021-01-22 02:41

I have problems to find out the correct launcher icon size for my shortcut.

On my Nexus 7.2 the value of android.R.dimen.app_icon_size (see code) is 96 pixels. But if I

3条回答
  •  误落风尘
    2021-01-22 02:55

    I have found out a working solution:

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private int launcherLargeIconSize() {
        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        return activityManager.getLauncherLargeIconSize();
    }
    
    int size1 = (int) getResources().getDimension(android.R.dimen.app_icon_size);
    int size2 = Build.VERSION.SDK_INT >= 11 ? launcherLargeIconSize() : 0;
    int size = size2 > size1 ? size2 : size1;
    

提交回复
热议问题