我有ListView
的布局。我需要将HeaderView
和FooterView
添加到ListView
。我添加了HeaderView和FooterView。 FooterView没有完全显示。
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>
爪哇: 我添加了这样的但是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的页脚中添加回收站视图。请提出您的想法。感谢