我的水平RecyclerView.Adapter
子类有一个简单的LinearLayout
行,后面有?attr/selectableItemBackgroundBorderless
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="60dp"
android:layout_height="match_parent"
android:gravity="center"
android:background="?attr/selectableItemBackgroundBorderless"
android:orientation="vertical"
>
<TextView/>
<TextView/>
</LinearLayout>
视图OnClickListener
的界面是从RecyclerView
设置的 - 这里没什么特别的。
OnClickListener正在处理&#34;选择&#34;视图的颜色,并将一些数据传递到另一个界面:
setAdapter(new CalendarViewAdapter(view -> {
int position = getChildLayoutPosition(view);
if (position == selectedDayPosition) return;
getAdapter().notifyItemChanged(selectedDayPosition);
selectedDayPosition = position;
getAdapter().notifyItemChanged(selectedDayPosition);
//view.setPressed(true);
//view.setPressed(false); <-- That didn't help as well (nor delaying in a handler etc.)
if (listener != null) {
listener.onDayPicked(CalendarPicker.this.days.get(selectedDayPosition).getPaginationInfo());
}
}));
我担心的是notifyItemChanged()
而不是涟漪的褪色,我最终得到了这个奇怪的结果:
我唯一的解释是这是?attr/selectableItemBackgroundBorderless
和?attr/selectableItemBackground
之间的一些奇怪组合。但我只想要无边框风格。
关于这个问题有几个问题,我尝试了所有的答案但不幸的是他们都使用?attr/selectableItemBackground
而不是无边界的变体。
任何有关我的UI困境的帮助都将受到高度赞赏!