Пример #1
0
  @Nullable
  private static Drawable getBestDrawable(Resources resources, @DrawableRes int id) {
    int[] densities =
        new int[] {
          DisplayMetricsCompat.DENSITY_XXXHIGH,
          DisplayMetricsCompat.DENSITY_XXHIGH,
          DisplayMetricsCompat.DENSITY_XHIGH,
          DisplayMetricsCompat.DENSITY_HIGH // 这都没有狗带吧
        };

    for (int density : densities) {
      try {
        return ResourcesCompat.getDrawableForDensity(resources, id, density, null);
      } catch (Exception ignored) {
      }
    }

    return null;
  }