Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android禁用clipping recyclerview';s项目_Android_Android Layout_Android Recyclerview - Fatal编程技术网

android禁用clipping recyclerview';s项目

android禁用clipping recyclerview';s项目,android,android-layout,android-recyclerview,Android,Android Layout,Android Recyclerview,第一张图片描述了我想要的,第二张图片是我得到的 黑色矩形表示回收视图,深红色表示其为项目。海军是ImageView 我在recyclerview所属的父视图组中尝试了clipChildren 有什么办法可以做到这一点吗?(我也尝试过动画) ---编辑--- 活动布局 请注意,我不能给出超过60dp的高度,内部项目具有固定高度(50dp) 使用,您可以在几秒钟内实现“查看超过查看”: 你所需要做的就是做适当的约束,上面的视图将被约束到另一个视图,他将在他上面 类似这样的内容: <?xml

第一张图片描述了我想要的,第二张图片是我得到的

黑色矩形表示回收视图,深红色表示其为项目。海军是
ImageView

我在recyclerview所属的父视图组中尝试了clipChildren

有什么办法可以做到这一点吗?(我也尝试过动画)

---编辑---


活动布局

请注意,我不能给出超过60dp的高度,内部项目具有固定高度(50dp)

使用,您可以在几秒钟内实现“查看超过查看”:

你所需要做的就是做适当的约束,上面的视图将被约束到另一个视图,他将在他上面

类似这样的内容:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<ImageView
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:src="@drawable/ic_launcher_background"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="Lower view" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="@+id/button2"
    app:layout_constraintEnd_toStartOf="@+id/button2"
    app:layout_constraintStart_toStartOf="@+id/button2"
    app:layout_constraintTop_toTopOf="@+id/button2"
    tools:text="top" />
</android.support.constraint.ConstraintLayout>


这就是如何将一个视图放在另一个视图的顶部,现在您要做的就是为您的案例实现它。

在您的示例中,视图保持架布局包含在RecyclerView中,RecyclerView包含在一个约束视图中

ConstraintLayout
---->回收视图
-------->ConstraintLayout(视图保持器)
------------>图像视图

根据

安卓:儿童

定义是否限制子对象在其边界内绘制


您希望视图保持架能够在视图保持架的边界之外绘制图像视图,并希望回收视图能够在回收视图的边界之外绘制视图保持架。要做到这一点,您需要在RecyclerView上设置android:clipChildren=“false”
,并设置顶级约束视图。

那么您想要一个看起来像他在
RecyclerView
项上的视图吗?@TamirAbutbul准确地检查我的答案@Slandrow您的项总是受到RecyclerView的约束。也许你可以给你的RecyclerView添加填充,以便在项目和RecyclerView的边界之间有更多的空间。RecyclerView正在剪切它的子项。也在RecyclerView上设置
android:clipChildren=“false”
。很抱歉我的问题模棱两可,因为
ImageView
是RecyclerView的项,所以我不能使用
匹配父项。在这种情况下,我假设内部视图的大小为50dp x 50dp,而您没有这样的大小。使用
匹配\u parent
,它与我的答案有什么关系?你能详细说明一下吗?编辑了我的问题,请检查我不太清楚,你希望你的项目像最低的图像吗?请注意,我必须将clipChildren和ClipPadding都设置为false。从回收商的角度来看,我必须这样做。希望它能帮助别人。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<ImageView
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:src="@drawable/ic_launcher_background"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="Lower view" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="@+id/button2"
    app:layout_constraintEnd_toStartOf="@+id/button2"
    app:layout_constraintStart_toStartOf="@+id/button2"
    app:layout_constraintTop_toTopOf="@+id/button2"
    tools:text="top" />
</android.support.constraint.ConstraintLayout>