Scroll 水平循环视图内部垂直循环视图滚动抖动
我使用的布局中使用了多个RecyclerView(水平)作为RecyclerView的项目视图。问题是垂直滚动并不像我预期的那样平滑。垂直滚动时有一些抖动(Parent RecyclerView)Scroll 水平循环视图内部垂直循环视图滚动抖动,scroll,android-recyclerview,Scroll,Android Recyclerview,我使用的布局中使用了多个RecyclerView(水平)作为RecyclerView的项目视图。问题是垂直滚动并不像我预期的那样平滑。垂直滚动时有一些抖动(Parent RecyclerView) 如何消除这些垂直滚动的震动?我曾经在父RecyclerView的OnBindViewHolder()方法中将适配器设置为水平RecyclerView。我已经解决了这个问题 在这种情况下,滚动性能要好得多 不要在OnBindViewHolder()父方法RecyclerView中将适配器设置为水平Rec
如何消除这些垂直滚动的震动?我曾经在父RecyclerView的OnBindViewHolder()方法中将适配器设置为水平RecyclerView。我已经解决了这个问题 在这种情况下,滚动性能要好得多 不要在
OnBindViewHolder()
父方法RecyclerView
中将适配器设置为水平RecyclerViews
而不是在第一次通过带有空或空数据列表的RecyclerView的onCreateViewHolder()
创建视图时设置它
只需在onBindViewHolder()
处用以前的空列表替换新的辅助数据列表,然后调用notifydataSetChanged()
到HorizontalAdapetr
这比onBindViewHolder()
中的setAdapter()
要好得多,您可以尝试这种方法
主要活动
public void initialize(List<List<ResponseObject>> responseObjectList) {
RecyclerView upperRecyclerView = (RecyclerView) this.findViewById(R.id.main_layout);
upperRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
VerticalAdapter adapter = new VerticalAdapter(this, responseObjectLists);
upperRecyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
public void初始化(列表响应对象列表){
RecyclerView Upper RecyclerView=(RecyclerView)this.findViewById(R.id.main_布局);
setLayoutManager(新的LinearLayoutManager(此,LinearLayoutManager.VERTICAL,false));
VerticalAdapter=新的VerticalAdapter(此,响应对象列表);
upperRecyclerView.setAdapter(适配器);
adapter.notifyDataSetChanged();
}
垂直循环视图适配器
public class VerticalAdapter extends RecyclerView.Adapter<VerticalAdapter.Holder> {
final private SearchActivity activity;
List<List<ResponseObject>> list;
public VerticalAdapter(SearchActivity activity, List<List<ResponseObject>> lists) {
this.list = lists;
this.activity = activity;
}
public Holder onCreateViewHolder(ViewGroup parent,int viewType) {
View itemLayoutView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.vertical_layout, null);
return new Holder(itemLayoutView);
}
public void onBindViewHolder(Holder viewHolder, int position) {
List<ResponseObject> objectList = list.get(position);
viewHolder.packageTitle.setText(objectList.get(0).getTag());
ImageAdapter imageAdapter = new ImageAdapter(activity, objectList);
viewHolder.horizontalRecyclerView.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false));
viewHolder.horizontalRecyclerView.setAdapter(imageAdapter);
viewHolder.horizontalRecyclerView.setNestedScrollingEnabled(false);
imageAdapter.notifyDataSetChanged();
}
public final static class Holder extends RecyclerView.ViewHolder {
protected TextView packageTitle;
protected RecyclerView horizontalRecyclerView;
public Holder(View view) {
super(view);
this.packageTitle = (TextView) view.findViewById(R.id.recycleViewTitle);
this.horizontalRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
this.horizontalRecyclerView.setLayoutManager(new LinearLayoutManager(this.horizontalRecyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
this.horizontalRecyclerView.setNestedScrollingEnabled(false);
horizontalRecyclerView.setAdapter(null);
}
}
public int getItemCount() {
return ListUtil.isEmpty(list) ? 0 : list.size();
}
}
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {
private List<ResponseObject> mainPageResponseList;
private SearchActivity activity;
public ImageAdapter(SearchActivity activity, List mainPageResponseList) {
this.mainPageResponseList = mainPageResponseList;
this.activity = activity;
}
public ImageAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemLayoutView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.horizontal_layout_view, null);
ViewHolder viewHolder = new ViewHolder(itemLayoutView);
return viewHolder;
}
public void onBindViewHolder(ViewHolder viewHolder, int position) {
ResponseObject object = mainPageResponseList.get(position);
Util.setImageUsingGlide(object.getImage(), viewHolder.imageView);
viewHolder.packageName.setText(object.getDestination());
viewHolder.packagePrice.setText(object.getPrice() + "");
viewHolder.imageView.setOnClickListener(null);
}
public final static class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView imageView;
protected TextView packageName;
protected TextView packagePrice;
public ViewHolder(View view) {
super(view);
this.imageView = (ImageView) view.findViewById(R.id.packageImage);
this.packageName = (TextView) view.findViewById(R.id.packageName);
this.packagePrice = (TextView) view.findViewById(R.id.packagePrice);
}
}
public int getItemCount() {
return ListUtil.isEmpty(mainPageResponseList) ? 0 : mainPageResponseList.size();
}
}
公共类垂直适配器扩展了RecyclerView.Adapter{
最终私人搜索活动;
名单;
公共垂直适配器(搜索活动、列表){
this.list=列表;
这个。活动=活动;
}
public Holder onCreateViewHolder(视图组父级,int-viewType){
View itemLayoutView=LayoutFlater.from(parent.getContext())
.充气(右布局、垂直布局、空);
返回新的持有者(itemLayoutView);
}
公共无效onBindViewHolder(Holder viewHolder,int位置){
List objectList=List.get(位置);
viewHolder.packageTitle.setText(objectList.get(0.getTag());
ImageAdapter ImageAdapter=新的ImageAdapter(活动,对象列表);
viewHolder.horizontalRecyclerView.setLayoutManager(新的LinearLayoutManager(活动,LinearLayoutManager.HORIZONTAL,false));
viewHolder.horizontalRecyclerView.setAdapter(图像适配器);
viewHolder.horizontalRecyclerView.setNestedScrollingEnabled(false);
imageAdapter.notifyDataSetChanged();
}
公共最终静态类持有者扩展了RecyclerView.ViewHolder{
受保护的TextView packageTitle;
受保护的回收视图水平回收视图;
公众持有人(视图){
超级(视图);
this.packagetTitle=(TextView)view.findViewById(R.id.recycleViewTitle);
this.horizontalRecyclerView=(RecyclerView)view.findViewById(R.id.RecyclerView);
this.horizontalRecyclerView.setLayoutManager(新的LinearLayoutManager(this.horizontalRecyclerView.getContext(),LinearLayoutManager.HORIZONTAL,false));
this.horizontalRecyclerView.setNestedScrollingEnabled(false);
horizontalRecyclerView.setAdapter(空);
}
}
public int getItemCount(){
返回ListUtil.isEmpty(list)?0:list.size();
}
}
水平循环查看适配器
public class VerticalAdapter extends RecyclerView.Adapter<VerticalAdapter.Holder> {
final private SearchActivity activity;
List<List<ResponseObject>> list;
public VerticalAdapter(SearchActivity activity, List<List<ResponseObject>> lists) {
this.list = lists;
this.activity = activity;
}
public Holder onCreateViewHolder(ViewGroup parent,int viewType) {
View itemLayoutView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.vertical_layout, null);
return new Holder(itemLayoutView);
}
public void onBindViewHolder(Holder viewHolder, int position) {
List<ResponseObject> objectList = list.get(position);
viewHolder.packageTitle.setText(objectList.get(0).getTag());
ImageAdapter imageAdapter = new ImageAdapter(activity, objectList);
viewHolder.horizontalRecyclerView.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false));
viewHolder.horizontalRecyclerView.setAdapter(imageAdapter);
viewHolder.horizontalRecyclerView.setNestedScrollingEnabled(false);
imageAdapter.notifyDataSetChanged();
}
public final static class Holder extends RecyclerView.ViewHolder {
protected TextView packageTitle;
protected RecyclerView horizontalRecyclerView;
public Holder(View view) {
super(view);
this.packageTitle = (TextView) view.findViewById(R.id.recycleViewTitle);
this.horizontalRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
this.horizontalRecyclerView.setLayoutManager(new LinearLayoutManager(this.horizontalRecyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
this.horizontalRecyclerView.setNestedScrollingEnabled(false);
horizontalRecyclerView.setAdapter(null);
}
}
public int getItemCount() {
return ListUtil.isEmpty(list) ? 0 : list.size();
}
}
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {
private List<ResponseObject> mainPageResponseList;
private SearchActivity activity;
public ImageAdapter(SearchActivity activity, List mainPageResponseList) {
this.mainPageResponseList = mainPageResponseList;
this.activity = activity;
}
public ImageAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemLayoutView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.horizontal_layout_view, null);
ViewHolder viewHolder = new ViewHolder(itemLayoutView);
return viewHolder;
}
public void onBindViewHolder(ViewHolder viewHolder, int position) {
ResponseObject object = mainPageResponseList.get(position);
Util.setImageUsingGlide(object.getImage(), viewHolder.imageView);
viewHolder.packageName.setText(object.getDestination());
viewHolder.packagePrice.setText(object.getPrice() + "");
viewHolder.imageView.setOnClickListener(null);
}
public final static class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView imageView;
protected TextView packageName;
protected TextView packagePrice;
public ViewHolder(View view) {
super(view);
this.imageView = (ImageView) view.findViewById(R.id.packageImage);
this.packageName = (TextView) view.findViewById(R.id.packageName);
this.packagePrice = (TextView) view.findViewById(R.id.packagePrice);
}
}
public int getItemCount() {
return ListUtil.isEmpty(mainPageResponseList) ? 0 : mainPageResponseList.size();
}
}
公共类ImageAdapter扩展了RecyclerView.Adapter{
私有列表mainPageResponseList;
私人搜索活动;
公共图像适配器(SearchActivity活动,列表mainPageResponseList){
this.mainPageResponseList=mainPageResponseList;
这个。活动=活动;
}
public ImageAdapter.ViewHolder onCreateViewHolder(视图组父级,int-viewType){
View itemLayoutView=LayoutFlater.from(parent.getContext())
.充气(右布局、水平布局视图,空);
ViewHolder ViewHolder=新的ViewHolder(itemLayoutView);
返回视图持有者;
}
公共无效onBindViewHolder(ViewHolder ViewHolder,int位置){
ResponseObject object=mainPageResponseList.get(位置);
Util.setImageUsingGlide(object.getImage(),viewHolder.imageView);
viewHolder.packageName.setText(object.getDestination());
viewHolder.packagePrice.setText(object.getPrice()+);
viewHolder.imageView.setOnClickListener(null);
}
公共最终静态类ViewHolder扩展了RecyclerView.ViewHolder{
受保护的图像视图;
受保护的TextView packageName;
受保护的文本视图包价格;
公共视图持有者(视图){
超级(视图);
this.imageView=(imageView)view.findViewById(R.id.packageImage);
this.packageName=(TextView)view.findViewById(R.id.packageName);
this.packagePrice=(TextView)view.findViewById(R.id.packagePrice);
}
}
public int getItemCount(){
返回ListUtil.isEmpty(mainPageResponseList)?0:mainPageResponseList.size();
}
}
main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivHolidayMainImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<ImageView
android:id="@+id/ivHotelImage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignTop="@id/ivHolidayMainImage"
android:background="@drawable/gradient_from_up_hotel_image" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="250dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
<TextView
android:id="@+id/mainPackageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
<TextView
android:id="@+id/mainPackageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackageTitle"
android:text="Andaman Islands"
android:textColor="@color/white"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/mainPackagePrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25000"
android:textColor="@color/white"
android:textSize="18dp" />
<TextView
android:id="@+id/journeyType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackagePrice"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="-100dp"
android:background="@drawable/gradient_from_down_hotel_image" />
</app.viaindia.views.ViaLinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_sms_black"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/recycleViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Beaches"
android:textColor="@color/black_light"
android:textSize="20dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:viaCustom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/packageImage"
android:layout_width="wrap_content"
android:layout_height="230dp"
android:scaleType="fitXY"
android:src="@drawable/cheese_1" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="160dp">
<TextView
android:id="@+id/tvNightAndDays"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="3 Night/4 days"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
垂直布局.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivHolidayMainImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<ImageView
android:id="@+id/ivHotelImage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignTop="@id/ivHolidayMainImage"
android:background="@drawable/gradient_from_up_hotel_image" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="250dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
<TextView
android:id="@+id/mainPackageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
<TextView
android:id="@+id/mainPackageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackageTitle"
android:text="Andaman Islands"
android:textColor="@color/white"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/mainPackagePrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25000"
android:textColor="@color/white"
android:textSize="18dp" />
<TextView
android:id="@+id/journeyType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackagePrice"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="-100dp"
android:background="@drawable/gradient_from_down_hotel_image" />
</app.viaindia.views.ViaLinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_sms_black"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/recycleViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Beaches"
android:textColor="@color/black_light"
android:textSize="20dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:viaCustom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/packageImage"
android:layout_width="wrap_content"
android:layout_height="230dp"
android:scaleType="fitXY"
android:src="@drawable/cheese_1" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="160dp">
<TextView
android:id="@+id/tvNightAndDays"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="3 Night/4 days"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
holizontal_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivHolidayMainImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<ImageView
android:id="@+id/ivHotelImage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignTop="@id/ivHolidayMainImage"
android:background="@drawable/gradient_from_up_hotel_image" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="250dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
<TextView
android:id="@+id/mainPackageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
<TextView
android:id="@+id/mainPackageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackageTitle"
android:text="Andaman Islands"
android:textColor="@color/white"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/mainPackagePrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25000"
android:textColor="@color/white"
android:textSize="18dp" />
<TextView
android:id="@+id/journeyType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mainPackagePrice"
android:text="Popular Pick"
android:textColor="@color/white"
android:textSize="12dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="-100dp"
android:background="@drawable/gradient_from_down_hotel_image" />
</app.viaindia.views.ViaLinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_sms_black"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/recycleViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Beaches"
android:textColor="@color/black_light"
android:textSize="20dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:viaCustom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/packageImage"
android:layout_width="wrap_content"
android:layout_height="230dp"
android:scaleType="fitXY"
android:src="@drawable/cheese_1" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="160dp">
<TextView
android:id="@+id/tvNightAndDays"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="3 Night/4 days"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
尝试在onbindViewHolder()而不是setAdapter()中通知DataSetChanged()。设置适配器