2013-12-11 5 views
0

페이지의 아래쪽 절반이 스크롤 가능한 결과보기 인 활동이 있습니다. 결과보기의 맨 위에는 텍스트와 버튼이있는 관련 정보가 있습니다. 이 버튼을 클릭하면 새 항목이이 상대 레이아웃에 나타나 검색을 구체화 할 수 있습니다. 이 부분은 모두 작동합니다. 그러나이 상대적 레이아웃 아래에서 검색 결과 목록을 추가해야합니다. 나는 listview와 함께이 작업을 했었지만, 페이지의 일부분 (헤더 상대 레이아웃 포함)의 전체 하단이 필요하고 scrollview에서리스트 뷰를 가질 수 없기 때문에이 작업은 효과가 없을 것이다.스크롤 가능한 헤더 섹션이있는 Android 스크롤 가능 결과보기

그래서 다른 뷰를 만들고 결과 데이터를 결과 데이터로 채우고이를 상대적 레이아웃 아래에 프로그래밍 방식으로 추가 할 수 있기를 바랬습니다. 아마 그 머리글 상대 레이아웃 아래에 선형 레이아웃을 갖는 것일 수도 있습니다.

나는이 생각과 함께 올바른 길을 가고 있습니까? 이 작업을 수행하는 올바른 방법은 무엇입니까?

내 앱의 최소 sdk 버전은 8입니다. 지원 라이브러리를 사용하고 있습니다.

편집 :, 난 그냥 (I 현재 별도의 .XML 파일로이) 내 결과 항목을 추가하려고해야하는지 알고 싶어 만약 그렇다면 기본적으로

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".DealerFragment" 
    android:descendantFocusability="beforeDescendants" 
    android:focusableInTouchMode="true" 
    android:background="@drawable/background"> 

    <ImageView 
     android:id="@+id/topBar" 
     android:background="#000000" 
     android:layout_width="match_parent" 
     android:layout_height="45dp" 
     /> 

    <ImageView 
     android:id="@+id/logoImageView" 
     android:layout_width="120dp" 
     android:layout_height="60dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:contentDescription="@string/CD_logo" 
     android:src="@drawable/logo" /> 

    <fragment 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

    <ScrollView 
     android:id="@+id/scrollBox" 
     android:layout_width="match_parent" 
     android:layout_height="220dp" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:background="#00000000" > 

     <RelativeLayout 
      android:id="@+id/scrollViewRelativeLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#00000000"> 

      <RelativeLayout 
       android:id="@+id/searchHeaderBox" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:background="#c0000000"> 

       <TextView 
        android:id="@+id/near" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerVertical="true" 
        android:text="@string/near" 
        android:textColor="#ffffff" /> 

       <TextView 
        android:id="@+id/nearZip" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toRightOf="@+id/near" 
        android:layout_marginLeft="4dp" 
        android:layout_centerVertical="true" 
        android:text="78749" 
        android:textColor="#ffffff" /> 

       <ImageView 
        android:id="@+id/narrowSearchImage" 
        android:layout_width="25dp" 
        android:layout_height="25dp" 
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/filter" 
        android:contentDescription="@string/CD_Narrow_Results"/> 

       <TextView 
        android:id="@+id/narrowSearchText" 
        android:layout_toLeftOf="@+id/narrowSearchImage" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerVertical="true" 
        android:text="@string/narrow_results" 
        android:textColor="#ffffff"/> 
      </RelativeLayout> 
      <LinearLayout 
       android:id="@+id/resultsLayout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/searchHeaderBox" 
       android:layout_marginTop="1dp" 
       android:orientation="vertical" 
       android:background="#00000000"> 
      </LinearLayout> 
     </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

: 여기에 내 현재 코드 내가 어떻게하는지. 또는 다른 장치가 있으면이 작업을 수행하는 데 사용해야합니다. 내 목표는 scrollview에서 모든 것을 스크롤하는 것입니다. 페이지가로드 될 때까지 얼마나 많은 결과 항목을 보유할지 알 수 없습니다.

+0

나는 당신이 성취하려는 것을 이해하는 데 약간의 어려움을 겪고 있습니다. 당신이 갖고있는 것과 원하는 것, 또는 어떤 코드의 스크린 샷을 게시 할 수 있습니까? –

+0

@MarioStoilov 물론입니다. 코드 및 추가 노트로 편집되었습니다. – PFranchise

+0

내가 시도 할이 해결책을 찾았습니다. http://stackoverflow.com/a/2397869/361815 – PFranchise

답변

1

에 대해 우리가 실제로ScrollViewListView를 넣어하는 방법!

사람들이 네가 할 수 없다고하지만 나는 길을 발견했다고 알고있다.


1ScrollView와 함께, 귀하의 ListView이 들어있는 레이아웃.

2.ListView을 포함한 레이아웃이있는 수업에 이것을 추가하십시오. 어댑터를 설치 한 후에 배치하십시오. 변경해야 할 것은 ListView 행 레이아웃의 높이 인 dp입니다.

int listViewAdapterSize = yourListView.getAdapter().getCount(); 
LayoutParams listViewParams = yourListView.getLayoutParams(); 

final float scale = getContext().getResources().getDisplayMetrics().density; 
int pixels = (int) ((listViewAdapterSize * dp) * scale + 0.5f); 
params.height = pixels; 

문제가 있으면 알려주세요.

관련 문제