안드로이드 개발 질문/답변
(글 수 45,052)
RelativeLayout을 사용 해서 택스트, 이미지 기반의 View 페이지를 개발하던 중 궁금한 부분이 있어 질문 드립니다.
먼저 레이아웃의 구조는
[ text1 ]
[ text2 ]
[ text3 ]
[ text4 ]
[img1][img2][img3][img4]
이런 구조이며,
text1, img1은 반드시 (데이터가 존재하여) 화면상에 보여지며, 그외 text2~4, img2~4의 경우 값이 없을 경우 숨기게 됩니다.(invisible)
이 경우 img 뷰간의 크기를 동일하게 화면의 1/4을 차지하게 하고, img4등 값이 비었을 경우 img간의 공백이 생기지 않고
밀착하게 하는 속성을 어떻게 줘야 할지 궁금합니다.
ex>
올바른 경우
[ text1 ]
[ text2 ]
[ text3 ]
[ text4 ]
[img1][img2][img3]
올바르지 않은 경우
[ text1 ]
[ text2 ]
[ text3 ]
[ text4 ]
[img1] [img2] [img3]
#수정: 데이터가 존재 하지 않을 경우 text2~4의 경우 gone으로 속성을 주고 img2~4의 경우 정렬을 위해 invisible로 줬습니다.
2010.09.17 17:33:18
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left"
>
<TextView
android:id="@+id/contents_type3_text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
></TextView>
<TextView
android:id="@+id/contents_type3_text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/contents_type3_text1"
android:textColor="#000000"
></TextView>
<TextView
android:id="@+id/contents_type3_text3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/contents_type3_text2"
android:textColor="#000000"
></TextView>
<TextView
android:id="@+id/contents_type3_text4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/contents_type3_text3"
android:textColor="#000000"
></TextView>
<ImageView
android:id="@+id/contents_type3_image1"
android:layout_width="79dp"
android:layout_height="79dp"
android:layout_below="@id/contents_type3_text4"
android:visibility="invisible"
></ImageView>
<ImageView
android:id="@+id/contents_type3_image2"
android:layout_width="79dp"
android:layout_height="79dp"
android:layout_toRightOf="@id/contents_type3_image1"
android:layout_below="@id/contents_type3_text4"
android:visibility="invisible"
></ImageView>
<ImageView
android:id="@+id/contents_type3_image3"
android:layout_width="79dp"
android:layout_height="79dp"
android:layout_toRightOf="@id/contents_type3_image2"
android:layout_below="@id/contents_type3_text4"
android:visibility="invisible"
></ImageView>
<ImageView
android:id="@+id/contents_type3_image4"
android:layout_width="79dp"
android:layout_height="79dp"
android:layout_toRightOf="@id/contents_type3_image3"
android:layout_below="@id/contents_type3_text4"
android:visibility="invisible"
></ImageView>
</RelativeLayout>
현재 이미지 정렬때문에 사이즈를 79dp로 fix 해 놓은 상태 입니다.
그 속성을 left로 주면 안되던가요?