当要拖动一个单元格时,我使用cardView.setCardElevation
api增加代码中的高程。当拖动开始时,由于某种原因,高程阴影会被剪裁。当一个单元被丢弃并且我在降低它之前检查高程时,它看起来没问题。因此即使高度很好,阴影也会因某种原因而被削减。我试图在recyclerview上添加填充到单元格和clipChildren = false
,但它没有任何区别。有什么想法吗?
RecyclerView:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/blrtMediaSelector_recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:scrollbars="vertical" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/blrtMediaSelector_addBtn"
app:layout_behavior="blrtapp.droid.mediaPicker.AddButtonBehaviour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="16dp"
app:fabSize="normal"
android:src="@drawable/ic_plus" />
</android.support.design.widget.CoordinatorLayout>
细胞:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mediaSelectorCell_cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="2dp"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true">
<RelativeLayout
android:id="@+id/mediaSelectorCell_parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp"
android:background="@color/white">
<!-- thumbnail -->
<ImageView
android:id="@+id/mediaSelectorCell_thumbnail"
android:layout_width="@dimen/blrtMediaSelectorCell_size"
android:layout_height="@dimen/blrtMediaSelectorCell_size"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="@drawable/splash" />
<!-- select icon -->
<ImageView
android:id="@+id/mediaSelectorCell_selectIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@id/mediaSelectorCell_thumbnail"
android:layout_alignBottom="@id/mediaSelectorCell_thumbnail"
android:layout_marginEnd="2dp"
android:layout_marginBottom="2dp" />
<!-- container for text fields -->
<LinearLayout
android:id="@+id/mediaSelectorCell_textContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/mediaSelectorCell_thumbnail"
android:paddingStart="6dp"
android:paddingEnd="2dp"
android:orientation="vertical">
<!-- primary text -->
<TextView
android:id="@+id/mediaSelectorCell_primaryTex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/charcoal"
android:ellipsize="end"
android:maxLines="1"
android:text="Primary text"
android:textSize="14sp" />
<!-- secondary text -->
<TextView
android:id="@+id/mediaSelectorCell_secondaryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/gray4"
android:text="secondary text"
android:textSize="12sp" />
</LinearLayout>
<!-- anchor to drag the cell -->
<ImageButton
android:id="@+id/mediaSelectorCell_dragAnchorButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="8dp"
android:scaleType="center"
android:background="@color/white"
android:src="@drawable/media_drag"
android:layout_centerVertical="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>