Gabriel Janucik
Gabriel Janucik

Reputation: 55

GridView specific items number height

I have GridView in LinearLayout in Fragment. I'm using ViewPager with few fragments, one in each page. Under ViewPager i have indicator. I'm using RelativeLayout as a root of layout and ViewPager is above indicator. Every of fragments in pager have GridView with 4 cells (2 columns x 2 rows).

In phone everything looks alright, but when i run my app on tablet i have a lot of empty space under GridView. One row of GridView have height in about 1/4 of available space, so GridView using only 1/2 empty space. In every cell i have only ImageView, and for some reason it looks like there have margins in sides.

How can measure and set height for row or cell or gridview? I've tried this solution but its not work for me.

Upvotes: 1

Views: 62

Answers (1)

amodkanthe
amodkanthe

Reputation: 4530

Create file dimens.xml in values directory. Put there

     <dimen name="row_height">300dp</dimen>.

This is default size.

Create directory values-large inside res folder.

Create file dimens.xml in values-large directory. Put there

  <dimen name="row_height">600dp</dimen>

This is size for tab

and inside layout file add

  android:layout_width="@dimen/row_height"

Upvotes: 1

Related Questions