當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapDrawable.setTargetDensity方法代碼示例

本文整理匯總了Java中android.graphics.drawable.BitmapDrawable.setTargetDensity方法的典型用法代碼示例。如果您正苦於以下問題:Java BitmapDrawable.setTargetDensity方法的具體用法?Java BitmapDrawable.setTargetDensity怎麽用?Java BitmapDrawable.setTargetDensity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.BitmapDrawable的用法示例。


在下文中一共展示了BitmapDrawable.setTargetDensity方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMoreSuggestionsHint

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize,
        final int color) {
    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(textSize);
    paint.setColor(color);
    final Rect bounds = new Rect();
    paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, MORE_SUGGESTIONS_HINT.length(), bounds);
    final int width = Math.round(bounds.width() + 0.5f);
    final int height = Math.round(bounds.height() + 0.5f);
    final Bitmap buffer = Bitmap.createBitmap(width, (height * 3 / 2), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(buffer);
    canvas.drawText(MORE_SUGGESTIONS_HINT, width / 2, height, paint);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(res, buffer);
    bitmapDrawable.setTargetDensity(canvas);
    return bitmapDrawable;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:19,代碼來源:SuggestionStripLayoutHelper.java

示例2: bitmap2Drawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static Drawable bitmap2Drawable(Bitmap bm) {
	if (bm == null) {
		return null;
	}
	BitmapDrawable bd=new BitmapDrawable(bm);
	bd.setTargetDensity(bm.getDensity());
	return new BitmapDrawable(bm);
}
 
開發者ID:Liuzhiyang94,項目名稱:ComponentProjectDemo,代碼行數:10,代碼來源:ACache.java

示例3: bitmap2Drawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static Drawable bitmap2Drawable(Bitmap bm) {
    if (bm == null) {
        return null;
    }
    BitmapDrawable bd = new BitmapDrawable(bm);
    bd.setTargetDensity(bm.getDensity());
    return new BitmapDrawable(bm);
}
 
開發者ID:devzwy,項目名稱:NeiHanDuanZiTV,代碼行數:10,代碼來源:ACache.java

示例4: bitmap2Drawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static Drawable bitmap2Drawable(Bitmap bm) {
	if (bm == null) {
		return null;
	}
	BitmapDrawable bd = new BitmapDrawable(bm);
	bd.setTargetDensity(bm.getDensity());
	return new BitmapDrawable(bm);
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:10,代碼來源:ACache.java

示例5: bitmap2Drawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * Bitmap 轉 Drawable
 */
@SuppressWarnings("deprecation")
public static Drawable bitmap2Drawable(Bitmap bm) {
    if (bm == null) {
        return null;
    }
    BitmapDrawable bd = new BitmapDrawable(bm);
    bd.setTargetDensity(bm.getDensity());
    return new BitmapDrawable(bm);
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:13,代碼來源:XulBitmapUtil.java


注:本文中的android.graphics.drawable.BitmapDrawable.setTargetDensity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。