2012-06-08 3 views
1

나는 을 가로로두기 위해 LinearLayout을 사용하고 있습니다. ImageView에 이미지가 있습니다. 이제 이미지 위에 작은 이미지를 ImageView에 추가해야합니다. 나는 많은 게시물을 보았지만 모두 Relativelayout 또는 Framelayout을 다룹니다. 다음은 내가 사용한 XML 코드 부분입니다.Android : ImageView의 이미지 위에 이미지 표시

<LinearLayout 
    android:id="@+id/relativeLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="10dip" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/imgmode31" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="10dp" 
     android:adjustViewBounds="true" 
     android:maxHeight="180dp" 
     android:maxWidth="140dp" 
     android:scaleType="fitXY" 
     android:src="@drawable/i5" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/imgmode32" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true" 
     android:longClickable="false" 
     android:maxHeight="180dp" 
     android:maxWidth="280dp" 
     android:scaleType="fitXY" 
     android:src="@drawable/i1" > 
    </ImageView> 

</LinearLayout> 

모든 도움을 주실 수 있습니다.

답변

1

이것은 선형 레이아웃이 방지해야하는 것입니다. 그러나 음의 패딩을 사용하여 다음 요소의 위치를 ​​무시할 수 있습니다. 이 문제는 서로 다른 화면 밀도에서 발생합니다.

이것이 표면보기의 의미라고 생각합니다. 화면 전체에 투명한 드로잉 표면을 제공하여 다른 뷰 위에 그릴 수 있습니다.

마지막 아이디어는 첫 번째 이미지를 선형 레이아웃 내부의 프레임 레이아웃에 배치하는 것입니다. 그런 다음 패딩을 사용하여 프레임 레이아웃에 중첩 된 이미지를 추가하여 배치 할 수 있습니다.

0

LinearLayout은 요소를 선형 적으로 배치합니다. 다른 요소 위에 요소를 배치하려면 FrameLayout 또는 RelativeLayout에 의존해야합니다.

변경할 경우

당신이 두 ImageView의 중복을 볼 수 LinearLayout FrameLayout A를.

1

당신이 그들의 HeightWidth 동일하게 각각의 서로 오버랩 할 수 ImagView을 원하는 경우 상대 레이아웃

<RelativeLayout 
android:id="@+id/relativeLayout2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 
    <ImageView  
    android:layout_height="wrap_content"  
    android:layout_width="wrap_content" 
    android:adjustViewBounds="true" 
    android:scaleType="fitXY" 
    android:src="@drawable/i5" 
    android:id="@+id/imgmode31" 
    android:maxHeight="180dp" 
    android:maxWidth="140dp"> 
    </ImageView> 
    <ImageView  
    android:layout_height="wrap_content"  
    android:layout_width="wrap_content" 
    android:scaleType="fitXY" 
    android:longClickable="false" 
    android:adjustViewBounds="true" 
    android:src="@drawable/i1" 
    android:id="@+id/imgmode32" 
    android:maxHeight="180dp" 
    android:maxWidth="280dp"> 
    </ImageView> 
</RelativeLayout> 

으로 쉽게 할 수 있으며 또한 런타임에 전면에 ImageView 중 하나를 가져올 수

+0

-1은 못생긴 포맷이지만 +1은 정답입니다. 나는 0시에 너를 떠날거야! – Justin

+0

@Justin조차도 내가 형식이 잘못된 코드를 붙여 놓았다는 사실을 알지 못했기 때문에 내 formating을 지적 해 주셔서 감사합니다. 내 모바일에서 해냈을 수도 있습니다. – Siddhesh

관련 문제