마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

TableLayout과 ListView

0 추천

 

다음과 같은 화면이 있습니다. 리니어레이아웃안에 테이블레이아웃으로 구성하였고..

ListView에 layout_span값을 주어서 위 화면의 가로부분을 가득 채우고 싶은데 아무리해도

안되네요.. 작성한 xml문서는 아래와 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:text="Top 50"
        android:textSize="35sp"/>
    <TableLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp" >
        <View 
            android:layout_width="match_parent"
            android:background="#999999"
            android:layout_height="1dp"/>
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:gravity="center"
                android:padding="3dp"
                android:layout_weight="1"
                android:text="순위" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:padding="3dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="ID"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:padding="3dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="점수"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:gravity="center"
                android:padding="3dp"
                android:layout_weight="1"
                android:text="날짜" />
            
         </TableRow>
		<View 
            android:layout_width="match_parent"
            android:background="#999999"
            android:layout_height="1dp"/> 
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
			
            <ListView
                android:id="@+id/TopList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_span ="4" >
            </ListView>
        </TableRow>
    </TableLayout>
</LinearLayout>

 

ListView를 4개의 컬럼너비만큼 차지하게 하려면 어떻게 해야할까요...

익명사용자 님이 2015년 3월 6일 질문

2개의 답변

+1 추천
 
채택된 답변
레이아웃 구조에서 굳이 TableLayout이 필요한가부터 다시한번 생각해보시기 바랍니다.

 

테이블의 타이틀에 해당하는 영역을 리스트의 row로 작성한 레이아웃을 include 해서 사용하면 서로 동일한 크기의 레이아웃으로 보일 수 있을 것 같습니다.

그것도 귀찮다면 더 쉽게 수정하는 방법은  타이틀 영역만 LinearLayout horizontal 속성으로 작성하셔도 되구요
Gradler (109,780 포인트) 님이 2015년 3월 6일 답변
tablelayout이 굳이 필요가 없었군요.. LinearLayout으로 해결했습니다..
+1 추천
listview 의 아이템 xml 에서
전체를 linearlayout 으로 하시고
네개를 동일하게 weight 주시면 되겠네요
근데 칼럼이 날짜와 점수가 바뀐거같네용 :)
mamondebaltob (32,750 포인트) 님이 2015년 3월 6일 답변
...