2012-09-03 6 views
0

레이아웃 인플레이레이터가있는 스크롤 레이아웃을 사용하여 데이터베이스의 데이터를 채 웁니다. 모든 것이 잘 작동하고 화면이 열립니다. 그러나 위로 스크롤하면 항목이 시작 부분에서 여백이 설정되는 시작 부분을지나 스크롤됩니다. 나는 항상 같은 위치에 머무르기를 원하는 정적 backgound 이미지를 사용하기 때문에 이것을하고있다. 스크롤 뷰를 수정하는 방법이 있습니까?스크롤 레이아웃에서 위치 고정

다음은 기본 페이지의 XML입니다.

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView android:id="@+id/ScrollView01" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" android:layout_width="fill_parent" 
    android:background="@drawable/backimage" 
    > 
    <LinearLayout 
     android:id="@+id/mylayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="70dp" 
     android:orientation="vertical" > 

    </LinearLayout> 
</ScrollView> 

이 내가 당신이 스크롤 내용이있는 ScrollView의 맨 아래 70dp 클립하려는 것을 의미하는 경우있는 ScrollView

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:orientation="vertical" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"><ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:gravity="right" 
    android:padding="10dp" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp" 
    android:paddingTop="10dp" 
    android:src="@drawable/nocarpic" /> 


    <TextView 
     android:id="@+id/TextView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="left" 
     android:paddingBottom="10dp" 
     android:paddingLeft="20dp" 
     android:paddingTop="10dp" 
     android:text="@+id/TextView01" > 

    </TextView> 
    <TextView 
     android:id="@+id/TextView02" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="20dp" 
     android:paddingBottom="10dp" 
     /> 

    <LinearLayout 
    android:id="@+id/horizontalLine" 
    android:layout_width="fill_parent" 
    android:layout_height="1dip" 
    android:background="#8B0000" 
    android:paddingRight="2dp" 
    /> 



</RelativeLayout> 

답변

1

에 추가 팽창 각 항목에 대한 XML입니다 제거하려고 LinearLayout의 여백 대신 ScrollView에서 android:paddingTop="70dp"을 설정하십시오. 기본적으로 ViewGroups는 하위보기를 채우기로 클립합니다.