当前位置: 首页>>代码示例>>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;未经允许,请勿转载。