title: I have created RecyclerView and when the screen orientation change then duplicate items are added to the top
body: <p>I have initialize RecyclerView in fragment as follows.</p>
  
  <pre><code> @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view= inflater.inflate(R.layout.fragment_home_page, container, false);
          initialiseView(view);
          recyclerView.setHasFixedSize(true);
          LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
          linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          recyclerView.setLayoutManager(linearLayoutManager);
          recyclerView.setAdapter(new HomepageRecyclerViewAdapter(getActivity()));
          return view;
      }
      private void initialiseView(View view){
          recyclerView=(RecyclerView)view.findViewById(R.id.recyclerView);
      }
  </code></pre>
  
  <p>Then I have created a RecyclerView adapter as follows.</p>
  
  <pre><code>public class HomepageRecyclerViewAdapter extends RecyclerView.Adapter&lt;HomepageRecyclerViewAdapter.ViewHolders&gt; {
      private Context context;
  
      public HomepageRecyclerViewAdapter(Context context) {
          this.context = context;
      }
  
      @Override
      public HomepageRecyclerViewAdapter.ViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.
                  from(parent.getContext()).
                  inflate(R.layout.homepage_recycler_view_content, parent, false);
          return new ViewHolders(itemView);
      }
  
      @Override
      public void onBindViewHolder(final HomepageRecyclerViewAdapter.ViewHolders holder, int position) {
          prepareHorizontalScrollView(holder.videoOuterParent);
      }
  
      @Override
      public int getItemCount() {
          return 50;
      }
  
      static class ViewHolders extends RecyclerView.ViewHolder {
          protected LinearLayout parentContent;
          protected ImageView videoImage;
          protected RelativeLayout videoInnerParent;
          protected HorizontalScrollView horizontalScrollView;
          protected LinearLayout videoOuterParent;
  
          public ViewHolders(View view) {
              super(view);
              parentContent = (LinearLayout) view.findViewById(R.id.parent_content);
              videoImage = (ImageView) view.findViewById(R.id.video_image);
              videoInnerParent = (RelativeLayout) view.findViewById(R.id.video_inner_parent);
              videoOuterParent = (LinearLayout) view.findViewById(R.id.video_outer_parent);
              horizontalScrollView = (HorizontalScrollView) view.findViewById(R.id.horizontal_scroll_view);
              videoInnerParent.getViewTreeObserver()
                      .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                          @Override
                          public void onGlobalLayout() {
  
                          }
                      });
          }
      }
  
      private void prepareHorizontalScrollView(LinearLayout videoOuterParent) {
          videoOuterParent.removeAllViews();
          for (int i = 0; i &lt; 10; i++) {
              RelativeLayout relativeLayout = new RelativeLayout(context);
              relativeLayout.setLayoutParams(new ViewGroup.LayoutParams(
                      ViewGroup.LayoutParams.MATCH_PARENT,
                      ViewGroup.LayoutParams.WRAP_CONTENT));
              final ImageView imageView = new ImageView(context);
              imageView.setAdjustViewBounds(true);
              imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
              imageView.setImageResource(R.drawable.gire_khursani);
              RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                      ViewGroup.LayoutParams.WRAP_CONTENT,
                      ViewGroup.LayoutParams.WRAP_CONTENT);
              layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
              layoutParams.setMargins(10, 10,0, 10);
              imageView.setLayoutParams(layoutParams);
              relativeLayout.addView(imageView);
              videoOuterParent.addView(relativeLayout);
          }
      }
  }
  </code></pre>
  
  <p>Now the problem i have faced is when i take screen to portrait mode to landscape mode the items is being duplicate at top.I cannot figure out the cause.</p>
  
  <p>Here is the link of the screen shot
  <a href="https://drive.google.com/file/d/0B2oBJsY3oyCtUTZsS1RmdC1RclU/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B2oBJsY3oyCtUTZsS1RmdC1RclU/view?usp=sharing</a></p>