2012-04-05 3 views
-1

이것을 알아 내려고 노력했습니다. 저는 Adroid를 처음 접해서 전체 화면을 scrollview로 가져 오려고합니다. 헤더 이미지와 목록입니다. 모든 스크롤을 함께 할 수 있습니다. 이 레이아웃을 사용하여 완료 할 수 있습니까? 감사!이 XML에 Scrollview를 추가 할 수 있습니까?

<?xml version="1.0" encoding="UTF-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/containerView" 
    android:background="@android:color/transparent"  
    android:padding="0dip" 
    android:layout_margin="0dip" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/headerImageContainer" 
     android:background="@android:color/transparent"  
     android:padding="0dip" 
     android:layout_margin="0dip" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentTop="true" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

      <ImageView 
        xmlns:android="http://schemas.android.com/apk/res/android"    
      android:id="@+id/headerImageView" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:scaleType="center" 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentTop="true"> 
     </ImageView> 

    </LinearLayout> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/listViewContainer" 
     android:background="@android:color/transparent"  
     android:paddingLeft="35dip" 
      android:paddingRight="35dip" 
      android:paddingTop="10dip" 
      android:paddingBottom="0dip" 

     android:layout_margin="0dip" 
     android:layout_weight="1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/headerImageContainer"> 

     <ListView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/listView" 
      android:background="@android:color/transparent"  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:cacheColorHint="#000000" 

      android:choiceMode="singleChoice" 
      android:layout_weight="1" 
      android:scrollbars="none"> 
     </ListView> 

    </LinearLayout> 

    </RelativeLayout> 

답변

0

스크롤을 함께 사용한다는 것은 무엇을 의미합니까? 항목 1에서 항목 n으로 이동할 때도 이미지를 스크롤하고 싶습니다. 스크롤보기를 사용하는 대신 목록보기를 첫 번째 행의 이미지와 통합하거나 목록 항목의 헤더로 사용하십시오. 스크롤보기는 목록보기에서 빌드 된 스크롤보기로 스크롤하는 데 사용됩니다. 모자는 항목을 스크롤합니다.

+0

답변을 주셔서 감사합니다 :) 내 전나무 시간이 질문을 요구! – user1120680

0

<LinearLayout 
...> 
    <ScrollView 
    ...> 
     Your original XML content here 
    </ScrollView> 
</LinearLayout> 

당신이 모든 것을 캡슐화 그리고 그것은 작동합니다.

+0

응답 해 주셔서 감사합니다. 아직 배울 점이 많습니다. Java 코드에서 Relativelayout을 원하기 때문에이 XML 코드에 어려움을 겪고 있습니다 ... 다른 팁은 크게 감사하겠습니다. 고마워요. :) – user1120680

+0

기꺼이 도와 드리겠습니다. "마크"기호를 클릭하여 대답을 수락하십시오. – Kai

+0

나는 일종의 일을하고 있지만 많은 수의 너비와 높이를 줄 수밖에 없었다. 이제 화면을 가로로 돌릴 때 맨 위의 헤더 이미지가 보이지 않게되고 세로로 다시 회전하면보기가 꺼지게된다. .. 헤더 이미지를 보려면 메뉴를 눌러야합니다. 어떤 도움을 주셔서 다시 한 번 감사드립니다! – user1120680

관련 문제