我需要一个像这样的RecyclerView:
它应该做:
每次显示7件物品(DONE)
将RecyclerView置于中央可见项目(DONE)的中心
当我向右/向左滚动时,中央项目将"突出显示"(按钮被选中>蓝色)(需要帮助)
当我点击一个按钮时,它将以平滑的scrool为中心(需要帮助)
我使用SnapHelperclass将RecyclerView置于中心项目的中心(我检索中心可见项目,让最近的孩子到屏幕中心)
我的适配器:
public class RvTrendsGraphAdapter extends RecyclerView.Adapter<RvTrendsGraphAdapter.ViewHolder> {
private float deviceWidth;
private float itemWidth;
private List<RvTrendsGraphModel> models;
private Context context;
public RvTrendsGraphAdapter(Context context, List<RvTrendsGraphModel> models) {
this.models = models;
this.context = context;
}
private Context getContext() {
return context;
}
public class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.rv_trends_graph_layout) PercentRelativeLayout rootLayout;
@BindView(R.id.rv_trends_graph_layout_superiore) PercentRelativeLayout layoutSuperiore;
@BindView(R.id.rv_trends_graph_layout_inferiore) RelativeLayout layoutInferiore;
@BindView(R.id.rv_trends_graph_vertical_progressbar) ProgressBar verticalProgressBar;
@BindView(R.id.rv_trends_graph_button) Button timeLapseButton;
public ViewHolder(View itemView) …Run Code Online (Sandbox Code Playgroud)