Android:网格项在第一行未对齐';s SuperRecyclerView GridLayout中的第二项

Android:网格项在第一行未对齐';s SuperRecyclerView GridLayout中的第二项,android,android-studio,android-recyclerview,sticky,gridlayoutmanager,Android,Android Studio,Android Recyclerview,Sticky,Gridlayoutmanager,我有GridLayout使用SuperRecyclerView和病态标题它工作正常,但在第一行的第二项中没有对齐,例如,如何解决我的问题,请帮助我的代码如下 activity.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:a

我有GridLayout使用SuperRecyclerView和病态标题它工作正常,但在第一行的第二项中没有对齐,例如,如何解决我的问题,请帮助我的代码如下

activity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white_color">

    <android.support.design.widget.CoordinatorLayout       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:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@color/white_color"
            android:fitsSystemWindows="true">

            <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:id="@+id/linearImageView"
                    android:layout_width="fill_parent"
                    android:layout_height="160dp"
                    android:layout_marginBottom="50dp"
                    android:layout_marginTop="50dp"
                    android:descendantFocusability="beforeDescendants"
                    android:focusableInTouchMode="true"
                    android:orientation="vertical"
                    android:padding="0dp">

                    <android.support.v4.view.ViewPager
                        android:id="@+id/mViewPager"
                        android:layout_width="match_parent"
                        android:layout_height="160dp"
                        android:overScrollMode="never" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/container_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <include
                        android:id="@+id/toolbar"
                        layout="@layout/toolbar" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/gray_hint_border_color" />

            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
    <com.malinskiy.superrecyclerview.SuperRecyclerView
            android:id="@+id/mRecycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:layout_empty="@layout/emptyview"
            app:mainLayoutId="@layout/layout_recyclerview_verticalscroll"
            app:recyclerClipToPadding="false"
            app:scrollbarStyle="outsideOverlay" />
</android.support.design.widget.CoordinatorLayout>

    <fragment
        android:id="@+id/fragment_navigation_drawer"
        android:name="com.vrin.sga.ui.FragmentDrawer"
        android:layout_width="@dimen/nav_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:layout="@layout/fragment_navigation_drawer"
        tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>

Home.java

mRecycler = (SuperRecyclerView) findViewById(R.id.mRecycler);
//        mRecycler.setLayoutManager(new LinearLayoutManager(mActivity));
        mRecycler.setLayoutManager(new GridLayoutManager(mActivity, 2));

        mListBeanArrayList = new ArrayList<>();

        mAdapter = new DashboardAdaper(mActivity, mListBeanArrayList);
        fillData();
        mAdapter.setHasStableIds(true);
        mRecycler.setAdapter(mAdapter);
        top = new StickyHeadersBuilder()
                .setAdapter(mAdapter)
                .setRecyclerView(mRecycler.getRecyclerView())
                .setStickyHeadersAdapter(new InitialHeaderAdapter(mListBeanArrayList,mActivity))
                .build();

        mRecycler.addItemDecoration(top);


private void fillData() {
        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("DEALS OF THE WEEK");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Pienaple Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);

        productListBean = new ProductListBean();
        productListBean.header = ("NEW GIFTS");
        productListBean.name = ("Chocolate Cake");
        productListBean.imgProduct = R.drawable.ic_launcher1;
        mListBeanArrayList.add(productListBean);
    }
mRecycler=(SuperRecyclerView)findViewById(R.id.mRecycler);
//mRecycler.setLayoutManager(新的LinearLayoutManager(MacActivity));
setLayoutManager(新的GridLayoutManager(MacActivity,2));
mListBeanArrayList=newarraylist();
mAdapter=新仪表板适配器(mActivity,mListBeanArrayList);
fillData();
mAdapter.setHasStableIds(true);
mRecycler.setAdapter(mAdapter);
top=新的StickyHeadersBuilder()
.setAdapter(mAdapter)
.setRecyclerView(mRecycler.getRecyclerView())
.SetStickyHeaderAdapter(新的InitialHeaderAdapter(mListBeanArrayList,MacActivity))
.build();
mRecycler.附加装饰(顶部);
私有void fillData(){
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“本周交易”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“皮纳普尔蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
productListBean=新的productListBean();
productListBean.header=(“新礼物”);
productListBean.name=(“巧克力蛋糕”);
productListBean.imgProduct=R.drawable.ic_\1;
添加(productListBean);
}