Reputation: 1121
Am using gridview to display an image and a textview.
After implementing this,
1) some times the alignment seems to be dancing while moving the gridivew 2) Some times the gridview get disappeared.
Can u plz advise how to resolve it ?
Thanks in advance.
Upvotes: 8
Views: 2969
Reputation: 1091
i have solved this problem replaced by
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="@dimen/big_margin"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/big_margin"
android:layout_height="wrap_content">
to
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="@dimen/big_margin"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/big_margin"
android:layout_height="@dimen/workoutlist_itemheight">
but really i don't know how did my issue solved.
thanks
Upvotes: 0
Reputation: 121
https://stackoverflow.com/a/5958097/2188257 this solution partialy solved the problem for me. When you set a fixed number of lines for the textview inside gridItems it doesnt fall apart anymore, but then you get the problem of having fixed number of lines for the text. its a problem cause i would like to reuse the layout for a grid menu on more than one place, and in some i have grids with big labels with 4-5 lines, and in a main menu labelshave just one line, but have to have 5 fixed lines because of other grids. I guess the solution could be to measure each element in the adapter and later setting layoutParams for the grid with max values... or creating multiple xml files for different uses of the grid.
Upvotes: 1
Reputation: 91
@Prasath, Set the Layout params for your images in Grid view. Your issue will be resolved. Since Grid view has issue with scrolling of uneven height objects. That's why your GridView disappears.
Upvotes: 9
Reputation: 15340
It means that the underlying item is not valid anymore; likely a null reference
Upvotes: 0