为RecyclerView 添加Header 的时候,ImageView 怎么都不能填充屏幕宽度,以为是图片问题,如下图:
右边明显缺了一部分,解决方案:Header 布局根换成Relayout,如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/index"
/>
</RelativeLayout>
效果如下图: