2012-09-04 3 views
2

한 화면에 두 부분 (두 조각 : 첫 번째 조각이 화면의 60 %를 차지하고 두 번째 조각이 나머지 부분을 차지함)이 있습니다. 첫 번째 조각에서는 gridview를 배치하고 두 번째 조각에서는 tableLayout을 만들었습니다. gridView에서 36 개의 ediText를 배치했습니다. down tablelayout에서 커스텀 키패드를 디자인했습니다. 첫 번째 프래그먼트에 정확히 맞게 10 개의 편집 문구가 필요하므로 gridview에 대한 세로 스크롤 막대를 비활성화했습니다. 인물 모드에서는 에뮬레이터에서 다소 작동하지만 풍경에서는 작동하지 않습니다. 그래서, 먼저 프래그먼트의 높이를 결정하기 때문에 프래그먼트의 높이와 폭을 얻을 수있는 방법이 있습니다. 측정 값을 얻은 후에도, 모드가 변경 될 때 현재 조각에 맞는 편집 텍스트를 만드는 방법은 무엇입니까? 소스를 검색했지만 명확한 해결책을 찾을 수 없습니다. 아래는 내 코드입니다. 모든 제안은 크게 감사하겠습니다. 미리 감사드립니다.스크롤 막대없이 화면에 gridview 요소를 맞추는 방법은 무엇입니까?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

     <FrameLayout 
       android:id="@+id/fLayout1" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="2" 
       android:background="@drawable/background3"> 
     <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/gridview" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:columnWidth="18dp" 
       android:numColumns="9" 
       android:verticalSpacing="0dp" 
       android:horizontalSpacing="5dp" 
       android:stretchMode="columnWidth" 
       android:gravity="center" 
       android:listSelector="@null"/> 
     </FrameLayout> 

     <FrameLayout 
       android:id="@+id/fLayout2" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="4" 
       android:background="@drawable/background2"> 

     <TableLayout 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/keypad" 
       android:orientation="vertical" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:stretchColumns="*"> 

     <TableRow> 
     <Button android:id="@+id/keypad_1" 
     android:text="1" 
     android:background="@drawable/custombutton"> 
     </Button> 
     <Button android:id="@+id/keypad_2" 
     android:text="2" 
     android:background="@drawable/custombutton"> 
     </Button> 
     <Button android:id="@+id/keypad_3" 
     android:text="3" 
     android:background="@drawable/custombutton"> 
     </Button> 

     <Button android:id="@+id/keypad_4" 
     android:text="4" 
     android:background="@drawable/custombutton"> 
     </Button> 

     <Button android:id="@+id/keypad_5" 
     android:text="5" 
     android:background="@drawable/custombutton"> 
     </Button> 

     </TableRow> 
     <TableRow> 



     <Button android:id="@+id/keypad_6" 
     android:text="6" 
     android:background="@drawable/custombutton"> 
     </Button> 

     <Button android:id="@+id/keypad_7" 
     android:text="7" 
     android:background="@drawable/custombutton"> 
     </Button> 
     <Button android:id="@+id/keypad_8" 
     android:text="8" 
     android:background="@drawable/custombutton"> 
     </Button> 
     <Button android:id="@+id/keypad_9" 
     android:text="9" 
     android:background="@drawable/custombutton"> 
     </Button> 

     <Button android:id="@+id/keypad_10" 
     android:text="C" 
     android:background="@drawable/custombutton"> 
     </Button> 

     </TableRow> 
     <TableRow> 
     <Button android:id="@+id/submit" 
     android:text="validate" 
     android:layout_span="5" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/custombutton"> 

     </Button> 
     </TableRow> 
     </TableLayout> 

     </FrameLayout> 
</LinearLayout> 

답변

0

gridView는 항상 스크롤 가능합니다. 당신은 (예를 어딘가에있다) 크기를 수정 한 사용자 지정을 만들 수 있습니다

당신이

+0

미안 해요, 난 36 edittexts이 정적 레이아웃을 사용 (인스턴스에 대한 TableLayout을 사용), 10 개 요소를해야합니다 알고있는 경우 . 따라서 Adapter 클래스를 사용하여 간단하고 완성 된 36 개의 edittext를 만들 수있었습니다. 테이블 레이아웃이나 다른 레이아웃을 사용하면 코드가 길어집니다. – Kanth

+0

사실. 사용자 정의 스크롤 할 수없는 gridview를 만들려고 할 수 있습니다. 트릭은 onMeasure를 수정하는 것입니다. 이 질문에 대한 답변보기 http://stackoverflow.com/questions/4523609/grid-of-images-inside-scrollview – njzk2

+0

안녕하세요, 오류가 발생하는 곳을 알려주실 수 있습니까? 당신이 제안한대로 사용자 지정 그리드 뷰를 만들었습니다. 내 활동 클래스에 다음 코드를 추가하면 응용 프로그램이 "응용 프로그램이 예기치 않게 중지되었습니다"라는 메시지를 표시합니다. gridView = (ExpandableHeightGridView) findViewById (R.id.myId); gridView.setAdapter (새 TextAdapter (this)); – Kanth

관련 문제