Reputation: 323
I have searched for solution regarding this issue but couldn't find any solution. I have a fragment which is above a recyclerView. The fragment I am using here is a fragment which came from a library. I have to show that View with a recyclerview. I have done this its working fine. But new requirement is it has to scroll with recyclerview. So for this reason I followed this solution. It seems to be fine but its not showing the entire fragment If I use the layout height to match parent or wrap content. But If I use a value like height = 300dp for that fragment then its showing. But I don't want like that it has to expand and show Can anybody help me to solve this?
this is my fragment.xml
<fragment android:id="@+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
and recyclerviewLayout.xml
<LinearLayout
android:id="@+id/listViewLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Thanks
Upvotes: 1
Views: 485
Reputation: 368
Simpler solution, i know its too late but maybe someone can use my answer :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:id="@+id/chart"
android:layout_alignParentTop="true"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:layout_below="@+id/chart"
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Right now i've set the height to 100dp just to show you that it renders correctly but you must set it to wrap content (as long as your fragment has an actual height it will render correctly)
Hope this helps :)
Upvotes: 1
Reputation: 250
Please try using like this.. It worked for me
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:id="@+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:below="@+id/chart"/>
</RelativeLayout> </ScrollView>
Upvotes: 1
Reputation: 325
If you want that both are on the same screen you should do something like:
<RelativeLayout
android:id="@+id/relativeViewLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<fragment android:id="@+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:below="@+id/chart"/>
</RelativeLayout>
If this isn't that you want, I didn't understand the question.
Upvotes: 1