下面是颜色的水平回收者视图。所以我有这个奇怪的问题,当键盘弹出打开时,回收器视图项的前半部分是不可见的。正如您在视图检查中看到的那样,视图仍然不可见。不确定发生了什么。任何帮助,将不胜感激。
截图
编辑: 对于投票的人请留下理由。
public class StylizedColorAdapter extends RecyclerView.Adapter<StylizedColorViewHolder> {
private List<String> colorList = new ArrayList<>();
private Subject<String> colorChangePublisher;
private static final int DEFAULT_COLOR_POSITION = 7;
public StylizedColorAdapter(Context context, Subject<String> colorChangePublisher) {
this.colorChangePublisher = colorChangePublisher;
String[] allColors = context.getResources().getStringArray(R.array.selectable_colors);
colorList.addAll(Arrays.asList(allColors));
}
@Override public StylizedColorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View row = inflater.inflate(R.layout.list_item_color_selector, parent, false);
return new StylizedColorViewHolder(row, colorChangePublisher);
}
@Override public void onBindViewHolder(StylizedColorViewHolder holder, int position) {
holder.setColor(colorList.get(position));
}
@Override public int getItemCount() {
return colorList.size();
}
public String getStartingColor() {
return colorList.get(DEFAULT_COLOR_POSITION);
}
}
public class StylizedColorViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.color_selector) CircleImageView ivColorSelector;
@BindView(R.id.color_selector_selected) ImageView ivColorSelected;
private View row;
private Subject<String> colorChangePublisher;
public StylizedColorViewHolder(View row, Subject<String> colorChangePublisher) {
super(row);
this.row = row;
this.colorChangePublisher = colorChangePublisher;
ButterKnife.bind(this, row);
}
public void setColor(String color) {
ivColorSelector.setColorFilter(Color.parseColor(color));
if (color.equalsIgnoreCase("#FFFFFF")) {
ivColorSelector.setBorderColor(ContextCompat.getColor(row.getContext(), R.color.colorLighterGrey));
} else {
ivColorSelector.setBorderColor(ContextCompat.getColor(row.getContext(), R.color.colorWhite));
}
ivColorSelector.setOnClickListener(v -> colorChangePublisher.onNext(color));
}
}
RecyclerView stylizedColorList = stylizedLayout.findViewById(R.id.stylized_text_color);
colorAdapter = new StylizedColorAdapter(getContext(), colorChangePublisher);
stylizedColorList.setAdapter(colorAdapter);