2011-04-30 5 views
0

다음과 같은 레이아웃이 있습니다. 나는 layout_weight = "1"을 사용하고 있습니다. 그래서 모든 것이 화면에 균일하게 맞춰질 것입니다. 사용자는 기본적으로 visibility = "gone"을 설정하여 이미지를 삭제할 수 있습니다.화면에 레이아웃 늘이기

사용자가 중간의 LinearLayout에서 두 이미지를 모두 삭제한다고 가정 해 봅시다. 레이아웃을 사라지게하고 싶습니다. 현재 두 이미지를 모두 삭제하면 빈 레이아웃이 그 사이에 틈을 남겨 놓습니다. 어떻게하면 다른 레이아웃이 빈 공간을 채울 수 있도록 제대로 작동합니까?

<LinearLayout android:orientation="vertical" android:width="fill_parent" android:height="fill_parent"> 
    <LinearLayout android:orientation="horizontal" android:layout_weight="1"> 
     <Image></Image> 
     <Image></Image> 
    </LinearLayout> 
    <LinearLayout android:orientation="horizontal" android:layout_weight="1"> 
     <Image></Image> 
     <Image></Image> 
    </LinearLayout> 
    <LinearLayout android:orientation="horizontal" android:layout_weight="1"> 
     <Image></Image> 
     <Image></Image> 
    </LinearLayout> 
</LinearLayout> 

답변

0

Java 코드에서이 작업을 수행 할 수 있습니다. 코드에서 LinearLayout (View의 하위 클래스)을 보이지 않게 설정합니다.

LinearLayout layout1 = this.findViewById(R.id.linearLayout1); 
//Some logic here to determine if the images in that layout have been removed or not 
//if they gone then.. 
layout1.setVisibility(View.INVISIBLE); 

이런 식으로. 또한 기존 레이아웃을 확장하여 남아있는 공백을 차지하는 지 확인하는 것이 좋습니다. 나는 이것을 테스트하지는 못했지만 이것이 당신의 솔루션을 해결할 것 같습니까? :-)