package net.dev.mission01;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.ScrollView;
public class MainActivity extends AppCompatActivity {
ScrollView scrollView01;
ScrollView scrollView02;
ImageView imageView01;
ImageView imageView02;
Resources res;
BitmapDrawable bitmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scrollView01 = (ScrollView) findViewById(R.id.scrollView01);
scrollView02 = (ScrollView) findViewById(R.id.scrollView02);
imageView01 = (ImageView) findViewById(R.id.imageView01);
imageView02 = (ImageView) findViewById(R.id.imageView02);
scrollView01.setHorizontalScrollBarEnabled(true); // 수평스크롤바 사용기능 설정
scrollView02.setHorizontalScrollBarEnabled(true); // 수평스크롤바 사용기능 설정
res = getResources();
bitmap = (BitmapDrawable) res.getDrawable(R.drawable.tulips);
int bitmap01Width = bitmap.getIntrinsicWidth();
int bitmap01Height = bitmap.getIntrinsicHeight();
imageView01.setImageDrawable(bitmap);
imageView01.getLayoutParams().width = bitmap01Width;
imageView01.getLayoutParams().height = bitmap01Height;
}
public void onButtonUpClicked(View v) { viewImage(bitmap, imageView01, imageView02); }
public void onButtonDownClicked(View v) { viewImage(bitmap, imageView02, imageView01); }
private void viewImage(BitmapDrawable bitmap, ImageView view, ImageView clear) {
view.setImageDrawable(bitmap);
view.getLayoutParams().width = bitmap.getIntrinsicWidth();
view.getLayoutParams().height = bitmap.getIntrinsicHeight();
clear.setImageResource(0);
}
}
'기타 개발 > Android' 카테고리의 다른 글
도전!05 고객 정보 입력 화면의 구성 (0) | 2017.06.29 |
---|---|
도전!04 영업관리 앱용 화면 만들기 (0) | 2017.06.26 |
도전!03 로그인 화면과 메뉴 화면 간단히 만들기 (0) | 2017.06.26 |
도전!02 SMS 입력 화면 만들고 글자수 표시하기 (0) | 2017.06.02 |
LinearLayout 정렬 (0) | 2017.06.01 |