여러 드로어 블을 하나의 드로어 블에 결합하고자합니다 (예 : 4 개의 사각형을 사용하여 Windows 로고와 같은 큰 사각형 하나 생성). 어떻게해야합니까?여러 드로어 블 합치기
8
A
답변
14
TableLayout
또는 일부 LinearLayout
을 사용하여이를 수행 할 수 있습니다. 그러나 원하는 경우 ImageView
안에 하나의 이미지를 만들어서 수동으로 Bitmap
을 만들어야합니다. 그것은 어렵지 않다 :
Bitmap square1 = BitmapFactory.decodeResource(getResources(), R.drawable.square1);
Bitmap square2 = BitmapFactory.decodeResource(getResources(), R.drawable.square2);
Bitmap square3 = BitmapFactory.decodeResource(getResources(), R.drawable.square3);
Bitmap square4 = BitmapFactory.decodeResource(getResources(), R.drawable.square4);
Bitmap big = Bitmap.createBitmap(square1.getWidth() * 2, square1.getHeight() * 2, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(big);
canvas.drawBitmap(square1, 0, 0, null);
canvas.drawBitmap(square2, square1.getWidth(), 0, null);
canvas.drawBitmap(square3, 0, square1.getHeight(), null);
canvas.drawBitmap(square4, square1.getWidth(), square1.getHeight(), null);
나는 위의 코드를 컴파일하지 않았다. 어떻게 할 수 있는지 보여줄뿐입니다. 나는 또한 같은 치수를 가진 정사각형 드로어 블을 모두 가지고 있다고 가정합니다. big
비트 맵을 원하는 곳 어디에서나 사용할 수 있습니다 (예 : ImageView.setImageBitmap()
).
5
LayerDrawable을 정확하게 사용할 수 있습니다.
관련 문제
- 1. 동일한 리소스 이미지의 여러 드로어 블
- 2. 하나의 xml 파일에서 여러 드로어 블
- 3. 내 curent 위치에 여러 드로어 블
- 4. 현지화 및 드로어 블
- 5. 태블릿에 드로어 블 드로잉
- 6. 캐시에 안드로이드로드 드로어 블
- 7. Android 드로어 블 질문
- 8. 드로어 블 리소스 얻기
- 9. 애니메이션 드로어 블 AnimationDrawable
- 10. 애니메이션 드로어 블 AnimationDrawable
- 11. Android - 드로어 블 언어
- 12. 다른 드로어 블 해상도
- 13. 안드로이드 드로어 블 폴더
- 14. 드로어 블 리소스 추가하기
- 15. Android에서 드로어 블 회전
- 16. XML로 드로어 블
- 17. 드로어 블 폴더
- 18. 애플리케이션간에 드로어 블 공유하기
- 19. 얼터너티브 드로어 블
- 20. 드로어 블 변수를 선언해야합니까?
- 21. 안드로이드 애니메이션 드로어 블 AnimationDrawable
- 22. Android - 불투명 페이드 드로어 블
- 23. android의 특정 드로어 블/레이아웃
- 24. SQLite의 드로어 블 이미지 android
- 25. 특정 높이의 드로어 블 만들기
- 26. Android setThumb (드로어 블) 가변형?
- 27. 경로에서 드로어 블 생성 문제
- 28. 드로어 블 폴더에서 이미지 읽기
- 29. Android 드로어 블 드로잉 성능?
- 30. 프로그래밍 방식으로 안드로이드로드 드로어 블
다음은 [Drawable Resources] (http://developer.android.com/guide/topics/resources/drawable-resource.html)에 대한 개발자 안내서입니다. 그것은 그림과 실행 가능한 코드로 훌륭한 세부 사항을 설명합니다. – Sam