当前位置: 首页>>代码示例>>Java>>正文


Java Resources.getDrawableForDensity方法代码示例

本文整理汇总了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;
    }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:22,代码来源:IconThemer.java

示例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;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:23,代码来源:LauncherActivityInfoCompatV16.java

示例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();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:11,代码来源:IconCache.java

示例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);
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:12,代码来源:ApiCompatibilityUtils.java

示例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;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:12,代码来源:ResolverActivity.java

示例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();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:11,代码来源:IconCache.java

示例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();
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:17,代码来源:IconCache.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ResourcesCompatIcsMr1.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ResourcesCompatApi21.java


注:本文中的android.content.res.Resources.getDrawableForDensity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。