将xml中默认的background
去掉,布局设置为android:layout_width="wrap_content"
android:layout_height="wrap_content"
在onBindViewHolder
方法中
设置setBackgroundResource
之前设置,使用下面俩个中的任意一个,即可保证notifyDataSetChanged();
时候item的大小不会改变。
holder.xx.setBackgroundResource(0);
holder.xx.setBackground(null);
if (item.isChecked()) {
holder.xx.setTextColor(context.getResources().getColor(R.color.color_4285f4));
holder.xx1.setBackgroundResource(0);
//holder.root.setBackground(null);
holder.xx1.setBackgroundResource(R.drawable.shape_stroke1_color_4285f4);
} else {
holder.xx.setBackgroundResource(0);
//holder.xx.setBackground(null);
holder.xx.setTextColor(context.getResources().getColor(R.color.color_5e5f66));
holder.xx1.setBackgroundResource(R.drawable.shape_stroke1_color_4285f4_2);
}