本文整理了Java中android.content.res.Resources.getDrawableForDensity
方法的一些代码示例,展示了Resources.getDrawableForDensity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resources.getDrawableForDensity
方法的具体详情如下:
包路径:android.content.res.Resources
类名称:Resources
方法名:getDrawableForDensity
暂无
代码示例来源:origin: android-hacker/VirtualXposed
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
Drawable getIcon(Resources res, int resId) {
Drawable result;
try {
result = res.getDrawableForDensity(resId, mIconDpi);
} catch (Resources.NotFoundException e) {
result = null;
}
return result;
}
代码示例来源:origin: ZieIony/Carbon
@Nullable
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Drawable getDrawableForDensity(int resId, int density, Theme theme) {
if (resId != 0 && getResourceTypeName(resId).equals("raw")) {
return new VectorDrawable(this, resId);
} else {
return super.getDrawableForDensity(resId, density, theme);
}
}
代码示例来源:origin: ZieIony/Carbon
@Nullable
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Drawable getDrawableForDensity(int resId, int density) throws NotFoundException {
if (resId != 0 && getResourceTypeName(resId).equals("raw")) {
return new VectorDrawable(this, resId);
} else {
return super.getDrawableForDensity(resId, density);
}
}
代码示例来源:origin: jaredrummler/AndroidProcesses
private Bitmap getFullResDefaultActivityIcon() {
if (defaultAppIcon == null) {
Drawable drawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
drawable = Resources.getSystem().getDrawableForDensity(
android.R.mipmap.sym_def_app_icon, dpi);
} else {
drawable = Resources.getSystem().getDrawable(
android.R.drawable.sym_def_app_icon);
}
defaultAppIcon = drawableToBitmap(drawable);
}
return defaultAppIcon;
}
代码示例来源:origin: jaredrummler/AndroidProcesses
private Bitmap getFullResIcon(Resources resources, int iconId) {
final Drawable drawable;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
drawable = resources.getDrawableForDensity(iconId, dpi, null);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
drawable = resources.getDrawableForDensity(iconId, dpi);
} else {
drawable = resources.getDrawable(iconId);
}
} catch (Resources.NotFoundException e) {
return getFullResDefaultActivityIcon();
}
return drawableToBitmap(drawable);
}
代码示例来源:origin: baidu/GPT
@Override
public Drawable getDrawableForDensity(int id, int density) throws NotFoundException {
try {
return super.getDrawableForDensity(id, density);
} catch (NotFoundException e) {
return mHostResources.getDrawableForDensity(id, density);
}
}
代码示例来源:origin: iqiyi/Neptune
@SuppressLint("NewApi")
@Override
public Drawable getDrawableForDensity(int id, int density) throws NotFoundException {
try {
return super.getDrawableForDensity(id, density);
} catch (NotFoundException e) {
return mHostResources.getDrawableForDensity(id, density);
}
}
代码示例来源:origin: iqiyi/Neptune
/**
* @param id 资源ID
* @param density 分辨率
* @param theme Theme
* @throws NotFoundException
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public Drawable getDrawableForDensity(int id, int density, Theme theme) throws NotFoundException {
try {
return super.getDrawableForDensity(id, density, theme);
} catch (NotFoundException e) {
return mHostResources.getDrawableForDensity(id, density, theme);
}
}
代码示例来源:origin: darkskygit/VirtualApp
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
Drawable getIcon(Resources res, int resId) {
Drawable result;
try {
result = res.getDrawableForDensity(resId, mIconDpi);
} catch (Resources.NotFoundException e) {
result = null;
}
return result;
}
代码示例来源:origin: stackoverflow.com
AppWidgetProviderInfo widgetProviderInfo
...
String packageName = widgetProviderInfo.provider.getPackageName();
Resources resources = getContext().getPackageManager()
.getResourcesForApplication(packageName);
Drawable drawable = resources.getDrawableForDensity(
widgetProviderInfo.previewImage, resources.getDisplayMetrics().densityDpi);
代码示例来源:origin: bzsome/VirtualApp-x326
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
Drawable getIcon(Resources res, int resId) {
Drawable result;
try {
result = res.getDrawableForDensity(resId, mIconDpi);
} catch (Resources.NotFoundException e) {
result = null;
}
return result;
}
代码示例来源:origin: gumingwei/WellSwipe
public Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
public Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
private Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: fookwood/Launcher3
private Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: corcoran/Hangar
public Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: enricocid/LaunchEnr
private Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi, mContext.getTheme());
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: klinker24/launcher3
private Drawable getFullResIcon(Resources resources, int iconId) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, mIconDpi);
} catch (Resources.NotFoundException e) {
d = null;
}
return (d != null) ? d : getFullResDefaultActivityIcon();
}
代码示例来源:origin: stackoverflow.com
ActivityInfo info = packageManager.getActivityInfo(componentName, PackageManager.GET_META_DATA);
Resources resources;
try {
resources = mPackageManager.getResourcesForApplication(
info.applicationInfo);
} catch (PackageManager.NameNotFoundException e) {
resources = null;
}
if (resources != null) {
int iconId = info.getIconResource();
if (iconId != 0) {
Drawable d;
try {
d = resources.getDrawableForDensity(iconId, DisplayMetrics.DENSITY_XHIGH);
} catch (Resources.NotFoundException e) {
d = null;
}
return d;
}
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
public Drawable getIcon(int density, IconPackHelper helper) {
if (helper != null && helper.isIconPackLoaded()) {
int iconId = helper.getResourceIdForActivityIcon(mLauncherActivityInfo.getComponentName().getPackageName(),
mLauncherActivityInfo.getComponentName().getClassName());
if (iconId != 0) {
isThemed = true;
return helper.getIconPackResources().getDrawableForDensity(iconId, density);
}
}
return mLauncherActivityInfo.getIcon(density);
}
内容来源于网络,如有侵权,请联系作者删除!