2016-01-20 2 views
0

У меня есть макет с ListView. Мне нужно добавить HeaderView и FooterView к этому ListView. Я добавил HeaderView и FooterView. FooterView не отображается полностью.Listview footer recyclerview не отображается

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: Я добавил, как это, но RecyclerView не показывая.

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); 

Можно ли добавить ресайлер в нижний колонтитул listview. Предложите свои идеи. Спасибо

ответ

1

Это происходит потому, что RecyclerView не может обернуть свой размер своим контентом. Вам необходимо предоставить другой LayoutManager, чтобы обработать его, я предлагаю вам исследовать вопрос this.

+0

Спасибо, что его рабочий штраф –

Смежные вопросы