1

첫 번째 Android 앱을 만들려고하는데 코드가 쉽게 보이지만 레이아웃에서 문제가 발생합니다.android 응용 프로그램에서 imageViews를 레이어하는 방법은 무엇입니까?

내 응용 프로그램은 "퍼즐"의 올바른 위치로 셰이프를 드래그 앤 드롭 응용 프로그램으로 매우 간단합니다. 여기 지금 보이는 방법의 예는 다음과 같습니다

enter image description here

내가 가지고 현재 다음 4 ImageView의 상단에있는 "빈 퍼즐"에 대한 하나의, 아래 모양의 각 1입니다. 내가이 작업을 수행하는 올바른 방법을 생각 하는 것은있을 퍼즐의 빈 지점의 각을 가지고있는 ImageView 나는이에 대한 올바른 생각하면

(화살표 예를 들어, ImageView을해야한다, 가리키는 것) ImageView을 "레이어"해야합니다. 3 개의 "빈 모양"이미지보기를 상단의 "퍼즐"이미지보기 위에 배치하십시오. 문제는 온라인상에서 어디서나 예제 나 제안을 찾을 수 없다는 것입니다.

  1. 는 의미는 3 개 ImageView의는 "배경"ImageView의 꼭대기에 앉아있을 수 있도록 하는가, 또는이 할 수있는 더 정확한 방법이 : 그래서 내 질문은?
  2. 만약 내가 올바른 방향으로 나아가고 있다면 누군가가 ImageView 층을 구축하는 방법을 설명하고 증명할 수 있습니까? 내 현재 화면

XML :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <ImageView 
     android:id="@+id/emptyPuz" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/EmptyPuzzle" /> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizantal" > 
     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" 
      android:src="@drawable/Circle" /> 
     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" 
      android:src="@drawable/Square" /> 
     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" 
      android:src="@drawable/Triangle" /> 
    </LinearLayout> 
</LinearLayout> 
+0

SDK 드래그 앤 드롭 시스템을 사용하거나 자체적으로 구현할 계획입니까? 그렇다면 각각의 빈 이미지에 대해 3 개의 ImageViews를 사용하십시오. 자신의 드래그 시스템을 사용한다면 빈 모양을 유지하기 위해 사용자 정의보기를 만들 것입니다. – Luksprog

+0

@Luksprog - SDK11에서 구현 된 드래그 앤 드롭 기능을 사용할 계획입니다. 나는 그것 때문에 3 개의 ImageView를 사용할 계획이지만, 내가 얻지 못하는 것은 내가 추가 할 3 개의 "빈 조각"이미지 뷰 뒤에 그 갈색 "퍼즐"이미지를 두는 방법이다. 그것은 네 번째'ImageView'입니까? 그렇다면 어떻게 다른 이미지 위에 하나의'ImageView '를 넣을 수 있습니까? – Mike

+0

3 개의 빈'ImageViews '를 보관하기위한'LinearLayout' (또는 다른 레이아웃)을 구축하고,'LinearLayout'의 배경으로 갈색 영역을 설정 한 다음 빈 셰이프를 세 가지'ImageViews'를 색상으로 설정합니다 (나는 빈 영역에 영향을 미치기를 원한다고 가정하고있다). 셰이프를보다 쉽게 ​​만들 수 있도록 사용자 지정 뷰를 만들어 ImageViews 대신 직접 그릴 수 있습니다. – Luksprog

답변

1

내가 사용하여 결국 해결책은 "퍼즐 기본"이미지에 background 세트와 새로운 LinearLayout을 추가이었다 세를 추가 그것에 "빈 퍼즐"조각과 새로운 이미지. 즉 :이 예에서와 같이 개별 이미지로 3 "빈"퍼즐 슬롯을 각각 헤어진 :

:

enter image description here

그런 다음 새로운 레이아웃에 배경으로 그들을 사용, 그래서 나는 전에이 코드를 한 경우

<ImageView 
    android:id="@+id/emptyPuz" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/EmptyPuzzle" /> 

지금이 :

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="@drawable/emptypuzzle" 
    android:orientation="horizontal" > 
    <ImageView 
     android:id="@+id/dropsquare" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:tag="square" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="false" 
     android:src="@drawable/emptysquare" /> 
    <ImageView 
     android:id="@+id/droptriangle" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:tag="triangle" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="false" 
     android:src="@drawable/emptytriangle" /> 
    <ImageView 
     android:id="@+id/dropcircle" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:tag="circle"   
     android:layout_height="wrap_content" 
     android:adjustViewBounds="false" 
     android:src="@drawable/emptycircle" /> 
</LinearLayout> 

이 결과 드래그 종료 및처럼 보이는 게임 드롭 :

enter image description here

귀엽지 만 내 아이는 좋아해. :)

관련 문제