<RelativeLayout
android:id="@+id/ntbt_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btbt"
android:layout_alignLeft="@id/btbt"
android:layout_marginTop="-3.33dip"
android:background="@drawable/ntbt_bg">
<ImageView
android:id="@+id/ntbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ntbt03"
android:layout_marginTop="3.33dip"
android:layout_marginLeft="83.34dip"
/>
<ImageView
android:layout_width="62.67dip"
android:layout_height="20.67dip"
android:background="#ff00ff00"
android:layout_alignBottom="@id/ntbt"
android:layout_alignLeft="@id/ntbt"
/>
</RelativeLayout>
코드 하이라이트 이용하면 이상하게 나와서 바로 적습니다...
이런 레이아웃이 있습니다.
첫 이미지뷰가 marginLeft를 사용하여 83.34dp 이동을 했고
두번째 이미지뷰는 크기가 변하기때문에 첫 이미지뷰의 바로 왼쪽에 붙이고 싶어서 toLeftOf를 사용했습니다.
그렇게 하고 보니 두번째 이미지뷰가 보이지 않는 현상이 생겨 확인을 해보니 첫 이미지 marginLeft 주기 전의 위치에 가 있는 것입니다.
이런 경우에는 어떻게 해야 두번째 이미지뷰가 첫 이미지 뷰의 왼쪽에 붙을까요?
참고로 첫번째 이미지뷰를 alignParentRight 속성을 줄 수가 없습니다. 화면 끝쪽이 아니라서 부모뷰가 길게 늘어나버려요...




이런 방법은 어떻까요? Linearlayout 을 감싸면 자동으로 첫번째 다음에 붙을거 같은데....한번시도해 보시죠~
<Linearlayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.33dip"
android:layout_marginLeft="83.34dip">
<ImageView
android:id="@+id/ntbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ntbt03"
/>
<ImageView
android:layout_width="62.67dip"
android:layout_height="20.67dip"
android:background="#ff00ff00"
/>
</Linearlayout>