本文整理匯總了Java中android.graphics.drawable.BitmapDrawable.setGravity方法的典型用法代碼示例。如果您正苦於以下問題:Java BitmapDrawable.setGravity方法的具體用法?Java BitmapDrawable.setGravity怎麽用?Java BitmapDrawable.setGravity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.BitmapDrawable
的用法示例。
在下文中一共展示了BitmapDrawable.setGravity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
* Puts {@link ViewBuilder}s riblet name in the background of the {@link View}
*
* @param viewBuilder a {@link ViewBuilder} which riblets name should be written.
* @param view a {@link View} to put the name behind.
*/
static void apply(final ViewBuilder viewBuilder, final View view) {
final Drawable oldBackground = view.getBackground();
final Bitmap bitmap;
if (oldBackground != null) {
bitmap = drawableToBitmap(oldBackground);
} else {
bitmap = Bitmap.createBitmap(FRAME_WIDTH, FRAME_HEIGHT, Bitmap.Config.ARGB_8888);
}
INSTANCE.writeOnBitmap(bitmap, getRibletName(viewBuilder));
final BitmapDrawable newBackground =
new BitmapDrawable(view.getContext().getResources(), bitmap);
newBackground.setGravity(Gravity.CENTER);
view.setBackground(newBackground);
view.setAlpha(XRAY_ALFA);
}