Recycler view标题错位于Position

时间:2015-08-12 09:20:47

标签: android android-layout android-fragments android-recyclerview recycler-adapter

我已经包含了一个带有标题包含2个按钮的Recycler视图。它工作正常,但当我尝试在应用程序内导航并在同一屏幕上回归时,标题按钮似乎向下移动其实际位置并重叠Recyclerview项目。

片段:

    mLinearLayoutManager = new LinearLayoutManager(mDashboardActivity);
    mHomeRecyclerView.setLayoutManager(mLinearLayoutManager);
    mHomeRecyclerViewAdapter = new HomeRecyclerViewAdapter(mDashboardActivity);
    mHomeRecyclerView.setAdapter(mHomeRecyclerViewAdapter);

    mHomeRecyclerViewHeader = RecyclerViewHeader.fromXml(mDashboardActivity, R.layout.header_home_recycle);
    mHomeRecyclerViewHeader.attachTo(mHomeRecyclerView, false);

适配器:

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycler_home, parent, false);
    return new SampleViewHolder(view);
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    SampleViewHolder viewHolder = (SampleViewHolder) holder;

}

@Override
public int getItemCount() {
    return 10;
}

public static class SampleViewHolder extends RecyclerView.ViewHolder {

    public TextView tvReqRec;

    public SampleViewHolder(View view) {
        super(view);
        tvReqRec = (TextView) view.findViewById(R.id.tvReqReceived);
        tvTitle = (TextView) view.findViewById(R.id.tvTitle);
    }
}

任何人都可以帮我解决问题。

0 个答案:

没有答案