【发布时间】:2015-11-19 20:04:40
【问题描述】:
我正在使用recyclerview 作为导航抽屉。我需要放置最后一项以对齐导航抽屉的底部。我怎样才能做到这一点。我已经尝试过在项目装饰中使用偏移量。它适用于我的手机,但我使用了硬编码值作为偏移量。我怎样才能动态地做到这一点。请帮我解决一下这个。 这是物品装饰的代码
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int itemPosition = parent.getChildAdapterPosition(view);
if(itemPosition == 2){
int height = parent.getMeasuredHeight();
int viewHeight = view.getMeasuredHeight();
outRect.top = parent.getHeight()/2 + 230;
view.setBackground(context.getResources().getDrawable(R.drawable.drawer_border_top));
}
}
}
【问题讨论】:
标签: android android-recyclerview navigation-drawer