<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="252px" android:layout_height="507px" android:padding="5px"> <ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:src="@drawable/icon"/> <TextView android:text="park" android:id="@+id/text" android:layout_toRightOf="@id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13sp" android:layout_marginTop="10dip"/> </RelativeLayout>
icontext.xml이고
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ListView
android:layout_width="252px"
android:layout_height="507px"
android:id="@+id/list"></ListView>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/iv"/>
</LinearLayout>
list.xml입니다.
리스트뷰에 이미지와 텍스트가 들어가는건데..
가로252px 에 세로 507px리스트뷰를 만들고 오른쪽 공간에는 이미지뷰를 두고 리스트뷰의 red,green,blue,yellow클릭시 오른쪽에 색깔을 채우는건데 캡쳐화면과 같이 이상하게 나옵니다..
고수님들 답변좀 부탁드려요~~
icontext.xml 이 ListView에 담길 Item의 Layout xml 인가요?
그렇다면 일단RelativeLayout의 android:layout_height="507px" 은 wrap Contents로 변경하시고,
자바코드는 어떻게 하신지 모르겠지만 아래 코드와 위 XML로 구동하니 정상적으로 나옵니다.
오른쪽에 setOnItemClickListener로 이미지를 바꾸는 코드만 추가하시면 되겟네요
Button sambeBtn;
public static final String [] LETTERS = {
"가","나","다","라","마"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
ListView list = (ListView)findViewById(R.id.list);
ArrayAdapter<String> adapter
= new ArrayAdapter<String>(this, R.layout.icontext, R.id.text, LETTERS);
list.setAdapter(adapter);
}




list.xml 이 이상한데요. 리스트뷰랑 이미지뷰랑 horizontal로 LinearLayout안에서 정렬되어있으니, 이상하긴 합니다. ListView를 Linear로 싼거와 이미지뷰만 Linear로 싸고 다시 이둘을 Relative나 Linear로 쌓아보십시요