Issue
Disclaimer: Fairly new to android programming, and trying to use android studio.
I am trying to "build" a background bitmap from several 32x32 png files in my resources. Lets say I have an array like {0,1,1,0,2,3}. I would then want a picture that would look like:
Grass, Water, Water, Grass, Flowers, Rock
I can do this by looping through the array and drawing each individual img that corresponds to that number, but is there a more efficient way to go about this?
or is there a better way to do this kind of drawing in general?
Solution
If you know what the background is supposed to look like and you have separate resources for each of the photos you could always make a few XML resources of stacking ImageViews.
Unless you want to do this dynamically, there should be no reason to do what I suggested over just opening the images up in a photo editor and doing some graphic design there. If on the other hand you want the pictures to change everytime, I would suggest making 4 or 5 different layouts and just doing an RNG with a switch case and transparent backgrounds.
Random rand = new Random();
int index = rand.nextInt((max-min)+1)+min);
switch (index)
{
case 1:
setContentView(R.layout.firstCorrespondingIndex);
reassignControls();
break;
case 2:
setContentView(R.layout.secondCorrespondingIndex);
reassignControls();
break;
default:
//Default bg
break;
}
Answered By - KoalaKoalified
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.