Closed twolight closed 8 years ago
Like this.Please fix.
And can you remove the padding between items
@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
Nice!
<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