안드로이드 개발 질문/답변
(글 수 45,052)
twitter 관련 어플을 만들고 있는데
생각보다 Layout을 잘 못만들겠네요.
기존 Twitter 화면처럼 왼쪽에는 이미지, 이미지 오른쪽에는 ID, ID오른쪽에는 텍스트글을 배치하려하는데...
텍스트글이 정렬이 되어서 ID오른쪽에만 디스플레이가 되네요.
제 의도는 ID오른쪽과 한줄이 넘어가면 이미지오륵쪽 그리고 ID 밑쪽에도 텍스트가 나왔으면 하는데.. 어떻게 배치해야하는지 잘모르겠습니다.
제가만들려고 하는 layout과 제가 만든 layout 이미지 첨부합니다.
제가 만들었던것은 relativelayout을 사용하였습니다. (linerlayout도 사용해봤는데 똑같이 나오더군요.)
제가 모르는 옵션이 있는것 같은데.. 고수님들 가르켜 주세요 (_ _)
생각보다 Layout을 잘 못만들겠네요.
기존 Twitter 화면처럼 왼쪽에는 이미지, 이미지 오른쪽에는 ID, ID오른쪽에는 텍스트글을 배치하려하는데...
텍스트글이 정렬이 되어서 ID오른쪽에만 디스플레이가 되네요.
제 의도는 ID오른쪽과 한줄이 넘어가면 이미지오륵쪽 그리고 ID 밑쪽에도 텍스트가 나왔으면 하는데.. 어떻게 배치해야하는지 잘모르겠습니다.
제가만들려고 하는 layout과 제가 만든 layout 이미지 첨부합니다.
제가 만들었던것은 relativelayout을 사용하였습니다. (linerlayout도 사용해봤는데 똑같이 나오더군요.)
제가 모르는 옵션이 있는것 같은데.. 고수님들 가르켜 주세요 (_ _)
2010.06.01 09:44:51
트윗터 방식은 분명 리스트뷰 아답타를 이용한 듯 한대요
일단 가장 기본적으로 텍스트뷰와 현제 배경창의 android:layout_width & height를 조절 하셔야 할 듯 한대요
하지만 결론적으론 리스트뷰 아답터를 이용하셔야 하지 않을까 생각됩니다.
2010.06.01 10:08:27
현재 ArrayAdapter를 확장해서 커스텀 뷰를 만들어서 사용하고 있습니다.
일단 가장 기본적으로 텍스트뷰와 현제 배경창의 android:layout_width & height를 조절 하셔야 할 듯 한대요 <-- 어떻게 하라는 말씀인지 잘 이해가 안되네요. 제가 구현한 것은 아래와 같습니다.
각 행의 layout은 다음과 같습니다.
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView_userImg"
android:scaleType="fitCenter" android:layout_marginRight="10px" android:layout_height="52px" android:layout_width="52px"> </ImageView>
<TextView
android:id="@+id/TextView_userId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/ImageView_userImg" android:textStyle="bold" android:layout_marginRight="10px"></TextView>
<TextView
android:id="@+id/TextView_userTweet"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/TextView_userId"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/TextView_userId"></TextView>
<TextView
android:text="time : xx:yy:zz"
android:id="@+id/TextView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_toRightOf="@+id/ImageView_userImg"></TextView>
<TextView
android:text="retweet"
android:id="@+id/TextView_retweet"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_alignParentRight="true" android:layout_marginRight="10px" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true"></TextView>
<TextView
android:text="reply"
android:id="@+id/TextView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_toLeftOf="@+id/TextView_retweet" android:layout_marginRight="10px" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true">
</TextView>
</RelativeLayout>
일단 가장 기본적으로 텍스트뷰와 현제 배경창의 android:layout_width & height를 조절 하셔야 할 듯 한대요 <-- 어떻게 하라는 말씀인지 잘 이해가 안되네요. 제가 구현한 것은 아래와 같습니다.
각 행의 layout은 다음과 같습니다.
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView_userImg"
android:scaleType="fitCenter" android:layout_marginRight="10px" android:layout_height="52px" android:layout_width="52px"> </ImageView>
<TextView
android:id="@+id/TextView_userId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/ImageView_userImg" android:textStyle="bold" android:layout_marginRight="10px"></TextView>
<TextView
android:id="@+id/TextView_userTweet"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/TextView_userId"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/TextView_userId"></TextView>
<TextView
android:text="time : xx:yy:zz"
android:id="@+id/TextView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_toRightOf="@+id/ImageView_userImg"></TextView>
<TextView
android:text="retweet"
android:id="@+id/TextView_retweet"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_alignParentRight="true" android:layout_marginRight="10px" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true"></TextView>
<TextView
android:text="reply"
android:id="@+id/TextView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/TextView_userTweet"
android:layout_toLeftOf="@+id/TextView_retweet" android:layout_marginRight="10px" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true">
</TextView>
</RelativeLayout>
2010.06.01 11:29:35
음... 하고자하시는 방법대로 Layout 을 구성하기는 쉽지 않을 것 같습니다. 대신 하나의 ImageView 와 하나의 TextView 만 사용하는 방법으로 구현하시면 어떨까요? 각 항목마다 TextView 를 사용하시는 대신, ID, 시간, Tweet 등등의 항목을 주욱 이어서 하나의 String 으로 구성한 다음에 하나의 TextView 에 설정하는 방식이면 가능할 것 같습니다.
각각의 문자열에 효과를 부여하는 방법은 회색님의 다음 글을 참고하세요.
2010.06.01 11:42:10
말씀하신대로 구현하면 (html 형식으로), 위 소스상에 (TextView_userId, TextView_userTweet) 두개를 하나의 TextView로 구성하면 Layout을 잡을 수 있을 것 같습니다. 그런데 문제점이 TextView_userId를 클릭하였을 때 이벤트를 받아 처리해야하는 경우가 있는데.. 제시해준 방법으로는 이벤트 처리가 곤란할 것 같습니다. ㅠ



