हालांकि इस सवाल का एक वर्ष से अधिक पुराना है, मैंने सोचा कि मैं हिस्सा था मैं क्या किया, किसी को हो सकता है इस तरह, या सिर्फ टाइप नहीं करना चाहते हैं और इस प्रकार कॉपी/पेस्ट कर सकते हैं: डी।
मेरा समाधान अंतिम आइटम में कुछ नीचे मार्जिन जोड़ना था।
सबसे पहले मैं यह निर्धारित यह पिछले आइटम है:
@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
}
}
तब मैं viewholder में एक विधि निचला हाशिया सेट करना होगा।
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);
}
}
और इस उदाहरण की पूर्णता के लिए, आयाम
<resources>
<dimen name="spot_list_footer_position_offset">-56dp</dimen>
</resources>
मुझे आशा है कि यह आपके लिए क्या देख रहे थे है।
यह। दूर तक सरल समाधान। –