Last active
September 3, 2015 20:12
-
-
Save mr5z/477cd2598cb103c5d3ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void setModuleInterface(Context context, int resourceImageId) { | |
int screenWidth = context.getResources().getDisplayMetrics().widthPixels; | |
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceImageId); | |
float aspectRatio = bitmap.getWidth() / (float) bitmap.getHeight(); | |
int height = Math.round(screenWidth / aspectRatio); | |
bitmap = Bitmap.createScaledBitmap(bitmap, screenWidth, height, true); | |
BITMAP_WIDTH = bitmap.getWidth(); | |
BITMAP_HEIGHT = bitmap.getHeight(); | |
setBackground(new BitmapDrawable(context.getResources(), bitmap)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment