kHRYSTAL / CircleRecyclerView

the library is a loop RecyclerView(expression), can show some effects when display
714 stars 100 forks source link

Item view in not horizontal center #3

Closed twolight closed 8 years ago

twolight commented 8 years ago

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="100dp" android:layout_height="100dp" android:background="@color/colorPrimaryDark"> <ImageView android:id="@+id/item_img" android:layout_gravity="center_horizontal" android:layout_width="48dp" android:layout_height="48dp" /> <TextView android:id="@+id/item_text" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="match_parent" />

In item_h.xml ,if android:layout_width="80dp" change to android:layout_width="100dp", Then The item view is not horizontal center

twolight commented 8 years ago

image Like this.Please fix.

twolight commented 8 years ago

And can you remove the padding between items

kHRYSTAL commented 8 years ago

@twolight thx reply I find this issue because scrollToPosition(DEFAULT_SELECTION) not work when onlayout at first time in real phone add code fix find center in loop:

+ private Handler mPostHandler = new Handler(){
+        @Override
+        public void handleMessage(Message msg) {
+            scrollToPosition(DEFAULT_SELECTION);
+        }
+    };
 if (mNeedLoop) {
//            scrollToPosition Notwork use delay
+            if (!mFirstOnLayout) {
+                mFirstOnLayout = true;
+                mPostHandler.sendEmptyMessage(0);
+            }
-            scrollToPosition(DEFAULT_SELECTION);
            mCurrentCenterChildView = findViewAtCenter();
            smoothScrollToView(mCurrentCenterChildView);
        }

and padding because item need scale , couldn't remove

twolight commented 8 years ago

Nice!