0

I have layout with ListView. I need to add HeaderView and FooterView to that ListView. I have added HeaderView and FooterView. FooterView not showing fully.

HeaderView:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:scaleType="fitXY"
    android:src="@drawable/giftcard_banner" />
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right|center"
    android:layout_marginRight="20dip"
    android:src="@drawable/loyalty_card" />
   </FrameLayout>

FooterView:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/snow_white_light"
android:orientation="vertical">

<TextView
    android:id="@+id/txtSimilarShops"
    style="@style/SimpleTextViewSmall"
    android:layout_gravity="left|top"
    android:background="@color/blue"
    android:gravity="left|center"
    android:padding="10dip"
    android:text="Similar Shops"
    android:textColor="@color/White" />

    <android.support.v7.widget.RecyclerView
     android:id="@+id/recyclerView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:scrollbars="horizontal"
     android:visibility="visible" />
   </LinearLayout>

Java: I have added like this but RecyclerView not showing.

 View headerView = getLayoutInflater().inflate(R.layout.header, null);
 listRewards.addHeaderView(headerView);
 View footerView = getLayoutInflater().inflate(R.layout.footer, null);
 txtSimilarShops = (TextView) footerView.findViewById(R.id.txtSimilarShops);
 recyclerView = (RecyclerView) footerView.findViewById(R.id.recyclerView);
 LinearLayoutManager layoutManager = new LinearLayoutManager(RewardsDetails.this);
 layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
 recyclerView.setLayoutManager(layoutManager);
 listRewards.addFooterView(footerView);

Is it possible to add recycler view in listview's footer. Please suggest your ideas. Thanks

Murali Ganesan
  • 2,815
  • 4
  • 18
  • 29

1 Answers1

1

It happens because a RecyclerView is not able to wrap his size with his content. You needs to provide another LayoutManager to handle it, i suggest you to investigate this question.

Community
  • 1
  • 1
The Dreams Wind
  • 2,917
  • 1
  • 15
  • 32