[英]Android: How to bring recyclerview scrollbar to front over RecyclerView.ItemDecoration?
[英]Focus effect in a RecyclerView - how to bring to front an item?
您可以更改触摸项目视图的背景颜色和文本颜色。 当用户点击它时。
我通过将项目视图发送到 Window.DecorView 来实现此效果。
您可以复制想要放在前面的所需视图(在这种情况下,您需要 ViewHolder 使用的布局),然后
((ViewGroup)activity.getWindow().getDecorView()).addView(yourView);
之后,您可以根据原始视图设置翻译。 新视图将位于上一个视图所在的同一位置的深色覆盖前面
编辑:我有一个您可以做什么的示例:以下代码是 C#(使用 Xamarin.Android),转向 Java 应该很容易。
var productView = productsLayoutManager.FindViewByPosition(position);
var cardView = productView.FindViewById<CardView>(Resource.Id.product_layout);
int[] location = new int[2];
productView.GetLocationOnScreen(location);
int left = location[0];
int top = location[1];
selectedView = LayoutInflater.Inflate(Resource.Layout.ProductRow2, null);
productsAdapter.CloneItemViewHolder(productView, ref selectedView);
selectedView.LayoutParameters = new FrameLayout.LayoutParams(cardView.LayoutParameters);
((ViewGroup)activity.Window.DecorView).AddView(selectedView, cardView.Width, cardView.Height);
selectedView.SetX(left);
selectedView.SetY(top);
selectedView.RequestLayout();
activity.DimBackground();
cardView 是 RecyclerView 项 Viewholder 的主要布局。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.