2017-07-01 64 views
0

在我的回收站的一切查看工作正常,除了這個問題,當片段開始時,第一個列表顯示在回收站查看有問題的設計和滾動後它已經正確和修復!原因是什麼? 這是我的看法回收適配器:第一個結果中的回收站視圖與滾動設計不同?

 View rootView = inflater.inflate(R.layout.fragment_order_list, container, 
      false); 

    recyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); 

    mAdapter = new MoviesAdapter(movieList); 
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext()); 
    recyclerView.setLayoutManager(mLayoutManager); 
    recyclerView.setItemAnimator(new DefaultItemAnimator()); 
    recyclerView.setAdapter(mAdapter); 

    prepareMovieData(); 

,這是我的XML的回收行:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="155dp" 
android:layout_marginBottom="10dp" 
android:background="@color/WhiteColor" 
tools:context="ir.himmel.visitors.himmel.LoginActivity" 
tools:layout_editor_absoluteX="0dp" 
tools:layout_editor_absoluteY="73dp"> 

<TextView 
    android:id="@+id/txt_finalPrice" 
    android:layout_width="313dp" 
    android:layout_height="26dp" 
    android:layout_marginRight="14dp" 
    android:layout_marginTop="10dp" 
    android:textColor="@color/year" 
    app:layout_constraintRight_toLeftOf="@+id/imageView6" 
    app:layout_constraintTop_toBottomOf="@+id/txt_TimeOrder" 
    tools:text="رقم کل سفارش: ۱۲۰۰۰۰ تومان" /> 

<TextView 
    android:id="@+id/txt_status" 
    android:layout_width="76dp" 
    android:layout_height="16dp" 
    android:layout_marginLeft="16dp" 
    android:layout_marginTop="14dp" 
    android:textColor="@color/year" 
    android:textSize="10sp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/imageView3" 
    tools:text="رقم کل سفارش: ۱۲۰۰۰۰ تومان" /> 

<ImageView 
    android:id="@+id/imageView8" 
    android:layout_width="23dp" 
    android:layout_height="25dp" 
    app:srcCompat="@drawable/itemsicon" 
    android:layout_marginRight="31dp" 
    app:layout_constraintRight_toRightOf="parent" 
    android:layout_marginTop="8dp" 
    app:layout_constraintTop_toBottomOf="@+id/imageView6" /> 

<TextView 
    android:id="@+id/title" 

    android:layout_width="420dp" 
    android:layout_height="30dp" 
    android:layout_marginRight="31dp" 
    android:layout_marginTop="7dp" 
    android:textColor="@color/title" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 

<ImageView 
    android:id="@+id/imageView4" 
    android:layout_width="23dp" 
    android:layout_height="26dp" 
    android:layout_marginRight="31dp" 
    android:layout_marginTop="43dp" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    app:srcCompat="@drawable/calendaricon" /> 

<ImageView 
    android:id="@+id/imageView6" 
    android:layout_width="23dp" 
    android:layout_height="25dp" 
    android:layout_marginRight="31dp" 
    android:layout_marginTop="8dp" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/imageView4" 
    app:srcCompat="@drawable/pricesicon" /> 

<TextView 
    android:id="@+id/year" 
    android:layout_width="313dp" 
    android:layout_height="26dp" 
    android:textColor="@color/year" 
    android:layout_marginTop="10dp" 
    app:layout_constraintTop_toBottomOf="@+id/txt_finalPrice" 
    app:layout_constraintRight_toLeftOf="@+id/imageView8" 
    android:layout_marginRight="15dp" /> 

<ImageView 
    android:id="@+id/imageView3" 
    android:layout_width="43dp" 
    android:layout_height="36dp" 
    android:layout_marginLeft="33dp" 
    android:layout_marginTop="73dp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    app:srcCompat="@drawable/tickicon" /> 

<TextView 
    android:id="@+id/editText2" 
    android:layout_width="2dp" 
    android:layout_height="90dp" 
    android:layout_marginBottom="0dp" 
    android:layout_marginLeft="30dp" 
    android:layout_marginTop="8dp" 
    android:background="@color/GeneralBackGround" 
    android:ems="10" 
    android:inputType="textPersonName" 
    app:layout_constraintBottom_toBottomOf="@+id/imageView3" 
    app:layout_constraintLeft_toRightOf="@+id/imageView3" 
    app:layout_constraintTop_toTopOf="@+id/imageView3" /> 

<TextView 
    android:id="@+id/txt_TimeOrder" 

    android:layout_width="312dp" 
    android:layout_height="24dp" 
    android:layout_marginRight="14dp" 
    android:layout_marginTop="8dp" 
    app:layout_constraintRight_toLeftOf="@+id/imageView4" 
    app:layout_constraintTop_toBottomOf="@+id/title" /> 

這就是結果!爲什麼這種行爲? 如你在第一個列表中顯示的結果,我們在設計中遇到問題,並在滾動後通過回收商進行修復查看!

this is first result that have problem :

after scroll it repaire design !

+0

在您的項目XML的結束,你有評論<! - - >但你不要關閉 –

+0

沒錯,我的錯誤,我忘了選擇這個iteml複製正確! – Mohammad

+0

好的。我看到你編輯了你的帖子,你是否關閉了你的ConstraintLayout? –

回答

1

我也有過這樣的問題一次,通過增加在recyclerView適配器這些方法解決了這個問題。這裏做的事情是,它重新加載行甚至在它是可見..

@Override 
    public void onViewAttachedToWindow(ViewHolder holder) { 
     super.onViewAttachedToWindow(holder); 
     int wPosition = holder.getAdapterPosition(); // if you need the position of current item else ignore.. 
     /* copy paste whatever you have in your onBindViewHolder method here */ 
    } 

    @Override 
    public void onViewRecycled(ViewHolder holder) { 
     super.onViewRecycled(holder); 
    /* copy paste whatever you have in your onBindViewHolder method here */ 

    } 
相關問題