Problem adding viewPager and inflating gridView in it
Opened this issue · 1 comments
Morteza-Rastgoo commented
This is my fragment layout containing StickyScrolView:
<com.emilsjolander.components.StickyScrollViewItems.StickyScrollView
android:id="@+id/sticky_scroll"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/layout_background"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/slider_container"
android:layout_width="fill_parent"
android:layout_height="@dimen/browse_fragment_slideshow_height"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="vertical">
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="@dimen/browse_fragment_slideshow_height"
android:layout_alignParentTop="true"
custom:auto_cycle="true"/>
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="@+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/slider"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
custom:selected_color="@color/ahangStyle_color"
custom:unselected_color="@color/layout_background"/>
</RelativeLayout>
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
style="@style/AhangStyle.Widget.TextView.Bold"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_below="@id/slider_container"
android:background="@color/gray_dark"
android:tag="sticky-nonconstant"
custom:pstsIndicatorHeight="5dp"
custom:pstsShouldExpand="true"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above= "@id/imageView"
android:layout_below="@id/tabs"/>
</RelativeLayout>
</com.emilsjolander.components.StickyScrollViewItems.StickyScrollView>
and on runtime fill the view pager with fragments containing this layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red">
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/layout_background"
android:gravity="center"
android:horizontalSpacing="0dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp">
</GridView>
</RelativeLayout>
but viewpager is not shown in runtime and it seems to have height of 0.
I tried setting android:layout_height="wrap_content" for GridView and it's parent but it has the same result.
When i set the viewPager's height to android:layout_height="700dp" or something, it works but the problem is that the height of grid view depends on nomber of items retrieved from server and it is not fixed.
how can i solve this?
xellDart commented
same problem