rağmen, ben ne yaptım paylaşmak istedim, birileri olabilir beğenmek, ya da sadece yazmak istemiyor ve kopyalamak/yapıştırmak: D.
Çözümüm son öğeye bir alt kenar boşluğu eklemek oldu.
@Override
public void onBindViewHolder(final ItemViewHolder holder, int position) {
....
Your other code
....
// Check if it is the last item and the list is not empty.
if(position == mItems.size()-1) {
// If so, add some margin to the element
holder.setBottomMargin(R.dimen.last_item_offset); // some dimension (or set a fixed amount of pixels
}
}
Sonra alt kenar boşluğunu ayarlamak için viewholder bir yöntemi vardır:
Öncelikle bunun son öğe olduğunu belirler.
class ItemViewHolder extends RecyclerView.ViewHolder {
private View mRootView;
private Context mContext;
public ItemViewHolder(View itemView) {
super(itemView);
mRootView = itemView;
mContext = itemView.getContext();
// do more stuff like binding views, etc
}
public void setBottomMargin(@DimenRes int margin){
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) mRootView.getLayoutParams();
layoutParams.bottomMargin = (int)getContext().getResources().getDimension(margin);
mRootView.setLayoutParams(layoutParams);
}
}
Ve bu örnekte tamlığı
, boyut
<resources>
<dimen name="spot_list_footer_position_offset">-56dp</dimen>
</resources>
Bunun Aradığın ne umut.
Bu. En basit çözüm. –