gpt4 book ai didi

android - RecyclerView 单元格的阴影被剪裁

转载 作者:行者123 更新时间:2023-11-30 00:06:42 27 4
gpt4 key购买 nike

我打算在用户开始拖动时增加单元格的高度,并在用户放下它时降低高度。拖动开始时,由于高程而产生的阴影会被剪裁。任何想法如何解决它?我试图在 recyclerview 上添加 clipChildren = falseclipToPadding = false 但没有任何区别。使用 cardView.setCardElevation 在代码中设置高度。有什么想法吗?

回收 View :

    <?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>

请忽略这只是为了满足最少细节的要求,因为代码比文本要多得多

最佳答案

如果按钮位于父级的底部,父 ViewGroup 也可能正在剪裁阴影。

确保父级有填充并在父级上设置 android:clipToPadding="false"

关于android - RecyclerView 单元格的阴影被剪裁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48839673/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com