不同手机上的展示情况
item 父布局的宽度设置为match_parent
<?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"
android:layout_margin="@dimen/dp_4">
<ImageView
android:id="@+id/iv_movie_cover"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"
android:background="@color/black" />
<TextView
android:id="@+id/tv_movie_search_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:gravity="center"
android:padding="@dimen/dp_4"
android:textColor="@color/white" />
</FrameLayout>
适配器中,解决宽度不能铺满
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_group_list, parent, false);//解决宽度不能铺满
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// View itemView = View.inflate(context,R.layout.item_recycle,null);
// return new ViewHolder(itemView);
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_group_list, parent, false);//解决宽度不能铺满
ViewHolder holder = new ViewHolder(view);
return holder;
}