我在滑动面板布局中的片段内有一个recylcer视图。
第一次实例化此布局时,回收器视图在项目之间有奇怪的间距,当手指抬起时(滑动面板后),这些项目会重新调整到正常状态
将手指从将面板滑动到展开状态之前和之后的图像
onBindView的recyclerview listadapter代码是 -
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
ImageView fromImage = new ImageView(
externalContact = ((Interaction)interactions.get(position)).getExternalContact();
teamMembers=((Interaction)interactions.get(position)).getTeamMembers();
photoUrl = externalContact.getPhoto().getContent();
String type = ((Interaction)interactions.get(position)).getType();
Log.d("InteractionList",photoUrl);
ImageView imageView[] = new ImageView[1];
imageView[0] = fromImage;
mLazyImageLoader.displayImage(photoUrl,imageView,R.drawable.default_contact_shape);
//fromImage.setImageDrawable(mContext.getResources().getDrawable(R.drawable.default_contact_shape));
fromImage.setPadding(
(int)mContext.getResources().getDimension(R.dimen.contacts_interaction_image_padding),
(int)mContext.getResources().getDimension(R.dimen.contacts_interaction_image_padding),
(int)mContext.getResources().getDimension(R.dimen.contacts_interaction_image_padding),
(int)mContext.getResources().getDimension(R.dimen.contacts_interaction_image_padding));
ImageView interactionIcon = new ImageView(mContext);
switch (type){
case "in" : interactionIcon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.interaction_inmail));
break;
case "out": interactionIcon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.interaction_outmail));
break;
case "exchange": interactionIcon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.interaction_mails_exchanged));
break;
default: Log.d("IteractionListAdapter","interactionType is wrong");
}
if (holder.interactionFromContainer.getChildCount() == 1) {
holder.interactionFromContainer.addView(fromImage);
holder.interactionFromContainer.addView(interactionIcon);
}
holder.interactionRow.setTag(position);
if (selectedPosition == position) {
if(position == 0){
holder.interactionRow.setBackgroundResource(R.drawable.drop_shadow);
}else {
holder.interactionRow.setBackgroundResource(R.drawable.drop_shadow_top_bottom);
}
holder.interactionRow.setPadding((int) mContext.getResources().getDimension(R.dimen.contacts_interaction_list_row_padding),
(int) mContext.getResources().getDimension(R.dimen.contacts_interaction_list_row_padding),
(int) mContext.getResources().getDimension(R.dimen.contacts_interaction_list_row_padding),
(int) mContext.getResources().getDimension(R.dimen.contacts_interaction_list_row_padding));
} else {
holder.interactionRow.setBackgroundColor(mContext.getResources().getColor(R.color.white));
}
//Integer []contacts = new Integer[]{1,2,3,4,5,6,7,8,9,10,11,12,13};
//ArrayList<Integer> contactsArray = new ArrayList<Integer>(Arrays.asList(contacts));
ContactsInteractionGridViewAdapter adapter = new ContactsInteractionGridViewAdapter(mContext,holder.interactionToContainerGridview,selectedPosition == position,stateRestored,teamMembers,mLazyImageLoader);
adapter.registerClickofMoreContactsInterfaceListener(this);
holder.interactionToContainerGridview.setAdapter(adapter);
Log.e("expanded", (selectedPosition == position) + " "+position);
}