2011-06-12 4 views
2

다음 지침을 따르고 있습니다. http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html이 목록/스크롤 뷰가 부모를 채우지 않는 이유는 무엇입니까?

다음 예에서는 목록 전체 화면을 보여줍니다. 그게 내가 원하는거야. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

로서는 결과 : examples result

내 결과 : I는 다음

my result

예시 2 XML 레이아웃을 사용한다. 1 페이지. 1 목록.

페이지 : 여기

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<LinearLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<ListView android:id="@id/android:list" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000fff" 
android:layout_weight="2" 
android:drawSelectorOnTop="false"> 
</ListView> 
<TextView android:id="@id/android:empty" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#FFff00" 
android:text="No data" 
/> 
</LinearLayout> 
</ScrollView> 

그리고는 목록에 대한 XML의 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<TextView android:id="@+id/tvAccountName"   
android:textSize="16sp"   
android:textStyle="bold" 
android:textColor="#FFFF00"   
android:layout_width="fill_parent"   
android:layout_height="fill_parent"/> 
<TextView android:id="@+id/tvAccountType" 
android:typeface="sans" 
android:textSize="14sp" 
android:textStyle="italic" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"/> 
<TextView android:id="@+id/tvAccountBalance"   
android:textSize="12sp"   
android:textStyle="bold"  
android:layout_width="wrap_content"   
android:layout_height="fill_parent"/> 
</LinearLayout> 

그리고 여기 매니페스트에서 항목입니다 :

<activity android:name=".listAccountsPage" 
       android:label="@string/app_name" 
       > 
     <intent-filter> 
      <action android:name="com.ourcreditunion.ourcumobile.LISTACCOUNTS" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
</activity> 

그래서 내가 무엇을 했는가 전체 화면이 아니게 만드시겠습니까?

+3

의 배경 속성을 설정합니다. 그러지 마. :) – adamp

답변

6

@adamp처럼 - 스크롤 뷰 내부에 목록보기를 넣지 마십시오. 어느 쪽이 두루마리 가겠습니까? xml도 더 간단해야합니다. 이 같은 시도 : 당신이 컬러 배경을 원하는 경우에

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ListView 
     android:layout_width="match_parent" 
     android:id="@+id/listView1" 
     android:layout_alignParentLeft="true" 
     android:layout_height="match_parent"/> 
</RelativeLayout> 

을, 당신은있는 ScrollView의 내부에있는 ListView가있는 RelativeLayout의

+0

방금 ​​adamps 제안을 넣었고 효과가있었습니다. 고마워요 :) – kireol

0

나는이 목록보기의 선언이

android:layout_weight="2" 

에서 오는 생각합니다. 주어진 숫자는 약간의 역 논리 ( )를 따르며, 크기가 클수록 뷰가 작아짐을 의미합니다.

관련 문제