2011-09-20 6 views
0

간단한 질문 : 스크롤 뷰 내부에있는 조각을 사용 가능한 공간을 모두 차지하고 싶습니다. 어떻게하면 될까요?ScrollView 내의 조각이 너무 작습니다.

세부 정보 : 부모 레이아웃에서 ScrollView 내부에 배치 한 조각이 있습니다. 이 스크롤 뷰는 상위 레이아웃의 대부분의 공간을 차지합니다. 그럼에도 불구하고 단편은 스크롤보기 내에서 매우 작게 나타납니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" android:orientation="vertical" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:gravity="center" android:stretchMode="columnWidth" 
    android:numColumns="auto_fit" android:horizontalSpacing="5dp" 
    android:verticalSpacing="5dp"> 
    <ScrollView android:layout_width="match_parent" 
     android:id="@+id/imagePickerScrollView" android:layout_weight="1.0" 
     android:layout_height="match_parent" android:background="@color/orange1" android:layout_gravity="fill_vertical"> 
    </ScrollView> 
    <LinearLayout android:id="@+id/linearLayout3" 
     android:layout_width="match_parent" android:layout_height="wrap_content" 
     android:background="@color/blue1"> 
     <Button android:layout_height="wrap_content" 
      android:layout_width="wrap_content" android:layout_weight="1.0" 
      android:text="@string/ImportSelectedButton" android:id="@+id/importSelectedButton" 
      android:layout_marginLeft="@dimen/standardMargin" 
      android:layout_marginTop="@dimen/standardMargin" 
      android:layout_marginBottom="@dimen/standardMargin" android:onClick="onImportSelected"></Button> 
     <Button android:layout_height="wrap_content" 
      android:layout_width="wrap_content" android:layout_weight="1.0" 
      android:text="@string/CancelButton" android:id="@+id/cancelButton" 
      android:layout_marginRight="@dimen/standardMargin" 
      android:layout_marginTop="@dimen/standardMargin" 
      android:layout_marginBottom="@dimen/standardMargin" android:onClick="onCancel"></Button> 
    </LinearLayout> 
</LinearLayout> 

그리고 마지막으로, 이것이다 : 이것은 부모 레이아웃의 XML이

<?xml version="1.0" encoding="utf-8"?> 
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ImagePickerGridView" android:orientation="vertical" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:gravity="center" android:stretchMode="columnWidth" 
    android:numColumns="auto_fit" android:horizontalSpacing="5dp" 
    android:verticalSpacing="5dp" android:background="@color/orange1"> 
</GridView> 

입니다 :

the fragment, or the scroll view, doesn't take the whole space

이 조각에 대한 XML입니다 : 사진이 보여 조각에 작업을 추가하는 방법 :

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.image_picker_1); 

    Log.d(CLASS_NAME, "onCreate"); 

    m_multiPicSelect = getIntent().getBooleanExtra(IntentHelper.MULTI_SELECT, false); 
    FragmentManager fragmentManager = getSupportFragmentManager(); 
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 

    Fragment fragment = new ImagePickerFragment(); 
    fragmentTransaction.add(R.id.imagePickerScrollView, fragment); 
    fragmentTransaction.commit(); 
} 
,

답변

0

확인을 추가, 나는 문제가 무엇인지 알게되었습니다. 밝혀진 GridView스크롤 가능 컨테이너이므로 ScrollView 안에 넣을 필요가 없습니다. 선형 레이아웃 안에 그리드 뷰를 넣으면 모든 것이 작동했습니다! 아직도 GridViewScrollView 안에 왜 있는지 잘 모릅니다. 왜냐하면 처음에는 거기에 없었어야했기 때문일 것입니다. :)

답장을 보내 주셔서 감사합니다.

0

이 @nik 말했듯이 ... ::

<ScrollView android:layout_width="fill_parent" 
     android:id="@+id/imagePickerScrollView" android:layout_weight="1.0" 
     android:layout_height="fill_parent" android:background="@color/orange1" android:layout_gravity="fill_vertical"> 
    </ScrollView> 
+0

아니요, 작동하지 않습니다 ...하지만 대답을 찾은 것 같습니다. GridView 자체가 스크롤 가능한 컨테이너라는 것을 깨닫지 못했습니다! 나는 해결책을 1 분 안에 게시 할 것이다. 감사! 덕분에 – Macondo2Seattle

0

을이 시도뿐만 아니라 android:fillViewport="true"

+0

! 그 결과, 문제는 GridView를 ScrollView에 넣는 것이 었습니다. 저는 이것을 별도의 대답으로 설명합니다. – Macondo2Seattle

관련 문제