diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/SpacesItemDecoration.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/SpacesItemDecoration.java new file mode 100644 index 0000000000..005984f991 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/SpacesItemDecoration.java @@ -0,0 +1,32 @@ +package com.mogo.module.v2x; + +import android.graphics.Rect; +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; + +/** + * 这是LinearLayoutManager设置Item间距的的一个辅助类 + * + * @author donghongyu + */ +public class SpacesItemDecoration extends RecyclerView.ItemDecoration { + private int space; + + public SpacesItemDecoration(int space) { + this.space = space; + } + + @Override + public void getItemOffsets(Rect outRect, View view, + RecyclerView parent, RecyclerView.State state) { + outRect.left = space; + outRect.right = space; + outRect.bottom = space; + + // Add top margin only for the first item to avoid double space between items + if (parent.getChildPosition(view) == 0) { + outRect.top = space; + } + } +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt index 4a844b9927..0c5dea786f 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt @@ -85,6 +85,7 @@ class V2XEventPanelFragment : MvpFragment + diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_panel_fragment_event_panel.xml b/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_panel_fragment_event_panel.xml index 38eab3dec5..ffea487a85 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_panel_fragment_event_panel.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_panel_fragment_event_panel.xml @@ -17,7 +17,7 @@ + + +