本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}