本文整理匯總了Java中android.content.res.Resources.getDrawableForDensity方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getDrawableForDensity方法的具體用法?Java Resources.getDrawableForDensity怎麽用?Java Resources.getDrawableForDensity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getDrawableForDensity方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRoundIcon
import android.content.res.Resources; //導入方法依賴的package包/類
private Drawable getRoundIcon(Context context,String packageName, int iconDpi) {
mPackageManager = context.getPackageManager();
try {
Resources resourcesForApplication = mPackageManager.getResourcesForApplication(packageName);
AssetManager assets = resourcesForApplication.getAssets();
XmlResourceParser parseXml = assets.openXmlResourceParser("AndroidManifest.xml");
int eventType;
while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT)
if (eventType == XmlPullParser.START_TAG && parseXml.getName().equals("application"))
for (int i = 0; i < parseXml.getAttributeCount(); i++)
if (parseXml.getAttributeName(i).equals("roundIcon"))
return resourcesForApplication.getDrawableForDensity(Integer.parseInt(parseXml.getAttributeValue(i).substring(1)), iconDpi, context.getTheme());
parseXml.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例2: getIcon
import android.content.res.Resources; //導入方法依賴的package包/類
public Drawable getIcon(int density) {
int iconRes = mResolveInfo.getIconResource();
Resources resources = null;
Drawable icon = null;
// Get the preferred density icon from the app's resources
if (density != 0 && iconRes != 0) {
try {
resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
icon = resources.getDrawableForDensity(iconRes, density);
} catch (NameNotFoundException | Resources.NotFoundException exc) {
}
}
// Get the default density icon
if (icon == null) {
icon = mResolveInfo.loadIcon(mPm);
}
if (icon == null) {
resources = Resources.getSystem();
icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
}
return icon;
}
示例3: getFullResIcon
import android.content.res.Resources; //導入方法依賴的package包/類
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();
}
示例4: getDrawableForDensity
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* @see android.content.res.Resources#getDrawableForDensity(int id, int density).
*/
@SuppressWarnings("deprecation")
public static Drawable getDrawableForDensity(Resources res, int id, int density) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return res.getDrawableForDensity(id, density, null);
} else {
return res.getDrawableForDensity(id, density);
}
}
示例5: getIcon
import android.content.res.Resources; //導入方法依賴的package包/類
@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;
}
示例6: getFullResIcon
import android.content.res.Resources; //導入方法依賴的package包/類
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();
}
示例7: getFullResIcon
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* 根據資源繪製指定圖標
* @param resources
* @param iconId
* @return
*/
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();
}
示例8: getDrawableForDensity
import android.content.res.Resources; //導入方法依賴的package包/類
public static Drawable getDrawableForDensity(Resources res, int id, int density) throws NotFoundException {
return res.getDrawableForDensity(id, density);
}
示例9: getDrawableForDensity
import android.content.res.Resources; //導入方法依賴的package包/類
public static Drawable getDrawableForDensity(Resources res, int id, int density, Theme theme) throws NotFoundException {
return res.getDrawableForDensity(id, density, theme);
}