import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView01, imageView02;
private ImageView imgTrapeziusR, imgTrapeziusL;
private ImageView imgShoulderR, imgShoulderL, imgChestR, imgChestL;
private ImageView imgBicepsR, imgBicepsL, imgSideR, imgSideL, imgAbdominalTop;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 뷰 객체 생성
imageView01 = (ImageView) findViewById(R.id.head);
imageView02 = (ImageView) findViewById(R.id.neck);
imgTrapeziusR = (ImageView) findViewById(R.id.trapeziusR);
imgTrapeziusL = (ImageView) findViewById(R.id.trapeziusL);
imgShoulderR = (ImageView) findViewById(R.id.shoulderR);
imgShoulderL = (ImageView) findViewById(R.id.shoulderL);
imgChestR = (ImageView) findViewById(R.id.chestR);
imgChestL = (ImageView) findViewById(R.id.chestL);
imgBicepsR = (ImageView) findViewById(R.id.bicepsR);
imgBicepsL = (ImageView) findViewById(R.id.bicepsL);
imgSideR = (ImageView) findViewById(R.id.sideR);
imgSideL = (ImageView) findViewById(R.id.sideL);
imgAbdominalTop = (ImageView) findViewById(R.id.abdominalTop);
Resources res = getResources(); // getResources() 메소드를 사용해 BitmapDrawable 객체를 만들 수 있다.
BitmapDrawable bitmap01 = (BitmapDrawable)res.getDrawable(R.drawable.head);
BitmapDrawable bitmap02 = (BitmapDrawable)res.getDrawable(R.drawable.neck);
BitmapDrawable bitmap03 = (BitmapDrawable)res.getDrawable(R.drawable.trapeziusright);
BitmapDrawable bitmap04 = (BitmapDrawable)res.getDrawable(R.drawable.trapeziusleft);
BitmapDrawable bitmap05 = (BitmapDrawable)res.getDrawable(R.drawable.shoulderright);
BitmapDrawable bitmap06 = (BitmapDrawable)res.getDrawable(R.drawable.shoulderleft);
BitmapDrawable bitmap07 = (BitmapDrawable)res.getDrawable(R.drawable.chestright);
BitmapDrawable bitmap08 = (BitmapDrawable)res.getDrawable(R.drawable.chestleft);
BitmapDrawable bitmap09 = (BitmapDrawable)res.getDrawable(R.drawable.bicepsright);
BitmapDrawable bitmap10 = (BitmapDrawable)res.getDrawable(R.drawable.bicepsleft);
BitmapDrawable bitmap11 = (BitmapDrawable)res.getDrawable(R.drawable.sideright);
BitmapDrawable bitmap12 = (BitmapDrawable)res.getDrawable(R.drawable.sideleft);
BitmapDrawable bitmap13 = (BitmapDrawable)res.getDrawable(R.drawable.abdominaltop);
int bitmapWidth01 = bitmap01.getIntrinsicWidth(); // 가로
int bitmapHeight01 = bitmap01.getIntrinsicHeight(); // 세로
int bitmapWidth02 = bitmap02.getIntrinsicWidth(); // 가로
int bitmapHeight02 = bitmap02.getIntrinsicHeight(); // 세로
int bitmapWidth03 = bitmap03.getIntrinsicWidth(); // 가로
int bitmapHeight03 = bitmap03.getIntrinsicHeight(); // 세로
int bitmapWidth04 = bitmap04.getIntrinsicWidth(); // 가로
int bitmapHeight04 = bitmap04.getIntrinsicHeight(); // 세로
int bitmapWidth05 = bitmap05.getIntrinsicWidth(); // 가로
int bitmapHeight05 = bitmap05.getIntrinsicHeight(); // 세로
int bitmapWidth06 = bitmap06.getIntrinsicWidth(); // 가로
int bitmapHeight06 = bitmap06.getIntrinsicHeight(); // 세로
int bitmapWidth07 = bitmap07.getIntrinsicWidth(); // 가로
int bitmapHeight07 = bitmap07.getIntrinsicHeight(); // 세로
int bitmapWidth08 = bitmap08.getIntrinsicWidth(); // 가로
int bitmapHeight08 = bitmap08.getIntrinsicHeight(); // 세로
int bitmapWidth09 = bitmap09.getIntrinsicWidth(); // 가로
int bitmapHeight09 = bitmap09.getIntrinsicHeight(); // 세로
int bitmapWidth10 = bitmap10.getIntrinsicWidth(); // 가로
int bitmapHeight10 = bitmap10.getIntrinsicHeight(); // 세로
int bitmapWidth11 = bitmap11.getIntrinsicWidth(); // 가로
int bitmapHeight11 = bitmap11.getIntrinsicHeight(); // 세로
int bitmapWidth12 = bitmap12.getIntrinsicWidth(); // 가로
int bitmapHeight12 = bitmap12.getIntrinsicHeight(); // 세로
int bitmapWidth13 = bitmap13.getIntrinsicWidth(); // 가로
int bitmapHeight13 = bitmap13.getIntrinsicHeight(); // 세로
// 크기 결정
imageView01.setImageDrawable(bitmap01);
imageView02.setImageDrawable(bitmap02);
imgTrapeziusR.setImageDrawable(bitmap03);
imgTrapeziusL.setImageDrawable(bitmap04);
imgShoulderR.setImageDrawable(bitmap05);
imgShoulderL.setImageDrawable(bitmap06);
imgChestR.setImageDrawable(bitmap07);
imgChestL.setImageDrawable(bitmap08);
imgBicepsR.setImageDrawable(bitmap09);
imgBicepsL.setImageDrawable(bitmap10);
imgSideR.setImageDrawable(bitmap11);
imgSideL.setImageDrawable(bitmap12);
imgAbdominalTop.setImageDrawable(bitmap13);
imageView01.getLayoutParams().width = bitmapWidth01;
imageView02.getLayoutParams().width = bitmapWidth02;
imgTrapeziusR.getLayoutParams().width = bitmapWidth03;
imgTrapeziusL.getLayoutParams().width = bitmapWidth04;
imgShoulderR.getLayoutParams().width = bitmapWidth05;
imgShoulderL.getLayoutParams().width = bitmapWidth06;
imgChestR.getLayoutParams().width = bitmapWidth07;
imgChestL.getLayoutParams().width = bitmapWidth08;
imgBicepsR.getLayoutParams().width = bitmapWidth09;
imgBicepsL.getLayoutParams().width = bitmapWidth10;
imgSideR.getLayoutParams().width = bitmapWidth11;
imgSideL.getLayoutParams().width = bitmapWidth12;
imgAbdominalTop.getLayoutParams().width = bitmapWidth13;
imageView01.getLayoutParams().height = bitmapHeight01;
imageView02.getLayoutParams().height = bitmapHeight02;
imgTrapeziusR.getLayoutParams().height = bitmapHeight03;
imgTrapeziusL.getLayoutParams().height = bitmapHeight04;
imgShoulderR.getLayoutParams().height = bitmapHeight05;
imgShoulderL.getLayoutParams().height = bitmapHeight06;
imgChestR.getLayoutParams().height = bitmapHeight07;
imgChestL.getLayoutParams().height = bitmapHeight08;
imgBicepsR.getLayoutParams().height = bitmapHeight09;
imgBicepsL.getLayoutParams().height = bitmapHeight10;
imgSideR.getLayoutParams().height = bitmapHeight11;
imgSideL.getLayoutParams().height = bitmapHeight12;
imgAbdominalTop.getLayoutParams().height = bitmapHeight13;
}
}
위의 코드는 단순히 여러 이미지를 화면에 뿌려주는 코드입니다.
여기서 imageView 우선순위(앞으로 나오게끔..)를 부여해주고 싶은데, 어떻게 하면 좋을까요?
예를들어, bicepsright <- 이 이미지를 가장 앞으로 나오게 만들고 싶습니다.