本文整理匯總了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);
}