1

following is my layout

ScrollView (FILL_PARENT, FILL_PARENT)
LinearLayout (FILL_PARENT, WRAP_CONTENT)
LinearLayout (FILL_PARENT, WRAP_CONTENT)
TextView (Choose your favourtie hotels)
LinearLayout (FILL_PARENT, WRAP_CONTENT)
GridView (10 rows)

However, only 1 and half rows are visible with vertical scrollbar. How can I ensure that GridView is fully visible?

thanks.

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
iuq
  • 1,487
  • 1
  • 20
  • 42

2 Answers2

0

Try working with weights:

ScrollView (FILL_PARENT, FILL_PARENT)
    LinearLayout (FILL_PARENT, WRAP_CONTENT)
        LinearLayout (FILL_PARENT, 0dp, WEIGHT 1)
            TextView (Choose your favourtie hotels)
        LinearLayout (FILL_PARENT, 0dp, WEIGHT 1)
            GridView (10 rows)
DroidBender
  • 7,762
  • 4
  • 28
  • 37
0

do not use GridView,ListView, etc inside a ScrollView as they have itself scrollable Views. just remove ScrollView it will shown properly.

Just use

LinearLayout (FILL_PARENT, FILL_PARENT, orientation="vertical")
        TextView (Choose your favourtie hotels)
        GridView (10 rows)

You can use

 LinearLayout (FILL_PARENT, FILL_PARENT, orientation="vertical")
        (Include any View, Set of Views)
        GridView (10 rows)
        After GridView you can't add any View.

but in worst case if it is must to use GridView inside a ScrolView. Then you nead to set the height of GridView in your Java code. Here is the link of measuring the height of list view you can do same for gridView.

Community
  • 1
  • 1
Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53
  • @Mohsin well its a kind of form and has other components as well in similar pattern LinearLayout [LinearLayout[TextView : Label], LinearLayout[EditText/GridView : Content] – iuq Jul 13 '12 at 07:16
  • @Mohsin I am trying to make it work but getting NullPointerException on listItem.onMeasure(0,0) – iuq Jul 13 '12 at 07:44