當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。