我对Recycler View Adapter
中的项目有疑问当项目从左向右滚动时,一切看起来都很好。 但是当将项目从右侧位置向右移动到左侧时,焦点项目会被截断至少一半。
我尝试改变回收器的宽度和高度,以及边距,但它不起作用
Recycler View Adapter
公共类SettingsSceneCardAdapter扩展了RecyclerView.Adapter {
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/settings_scene_card_item_view_focused"
android:layout_width="215dp"
android:layout_height="328dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp" />
<RelativeLayout
android:id="@+id/settings_scene_card_item_view"
android:layout_width="185.5dp"
android:layout_height="278dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="50dp"
android:gravity="center">
<ImageView
android:id="@+id/settings_scene_card_main_image_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="68dp"
android:layout_marginTop="50dp" />
<TextView
android:id="@+id/settings_scene_card_item_text_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_scene_card_main_image_icon"
android:gravity="center" />
</RelativeLayout>
foo <- function(x) {y <- table(x); paste(rbind(y, names(y)), collapse = "")}
df %>%
group_by(truck_no) %>%
mutate(type = foo(type)) %>%
summarise_all(first)
## A tibble: 2 x 5
# truck_no start_time end_time ctr_no type
# <fctr> <fctr> <fctr> <fctr> <chr>
#1 ABC123 20-05-2016 06:53 20-05-2016 08:53 ERT09 2D2R
#2 ERT123 21-05-2016 06:53 21-05-2016 08:53 QRT34 1D1R
答案 0 :(得分:0)
使用Snaphelper。这是为了在recyclerview中滚动时捕捉中心的项目。
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);