当前位置: 首页 > 知识库问答 >
问题:

Cardview不使用layertype软件

李兴安
2023-03-14

我需要画一些路径,并在下面显示它。所以我更喜欢下面的结构。

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorPrimaryDark"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark"
        app:contentInsetEnd="0dp"
        app:contentInsetLeft="0dp"
        app:contentInsetRight="0dp"
        app:contentInsetStart="0dp"
        app:layout_scrollFlags="scroll|enterAlways">

        <ImageView
            android:id="@+id/imageMenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/app_name"
            android:padding="@dimen/d10dp"
            android:src="@drawable/ico_menu"/>

        <TextView
            android:id="@+id/toolbarTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/T_HEADER"
            android:textColor="@android:color/white"
            android:textSize="@dimen/d18sp"/>
        <ImageView
            android:id="@+id/imageAdd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:alpha="0.6"
            android:contentDescription="@string/app_name"
            android:padding="@dimen/d10dp"
            android:src="@drawable/ic_add_circle"/>


    </android.support.v7.widget.Toolbar>

</android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollGraph"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingTop="@dimen/d20dp">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/layoutGraph"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewEvents"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layoutManager="LinearLayoutManager"/>
        </FrameLayout>

    </android.support.v4.widget.NestedScrollView>

<TextView
    android:id="@+id/textNoData"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="@string/TG_NO_DATA"
    android:textColor="@android:color/black"
    android:textSize="@dimen/d14sp"
    android:visibility="gone"/>

我能够画出我的观点并填写recyclerview。看起来不错。

现在我的问题是我正在使用Cardview回收器视图中显示项目。

以下是自定义单元格的代码。

    <android.support.v7.widget.CardView
        android:id="@+id/cardViewGraph"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        app:cardCornerRadius="@dimen/d5dp"
        app:cardElevation="@dimen/d5dp"
        app:cardUseCompatPadding="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:baselineAligned="false"
            android:orientation="horizontal"
            android:weightSum="4">

                <ImageView
                    android:id="@+id/imageTimeMap"
                 android:layout_width="0dp"
                         android:layout_height="match_parent"
                         android:layout_weight="1.8"
                    android:contentDescription="@string/app_name"
                    android:scaleType="centerCrop"
                    android:src="@drawable/bg_gray_placeholder"/>



            <LinearLayout android:layout_width="0dp"
                          android:layout_height="match_parent"
                          android:layout_weight="2.2"
                          android:orientation="vertical"
                          android:padding="@dimen/d3dp">

                <LinearLayout android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:gravity="center_vertical"
                              android:orientation="horizontal">

                    <TextView android:id="@+id/textTimeMapType"
                              android:layout_width="0dp"
                              android:layout_height="wrap_content"
                              android:layout_weight="1"
                              android:drawablePadding="@dimen/d3dp"
                              android:gravity="center_vertical"
                              android:textSize="@dimen/d10sp"/>

                    <ImageView
                        android:id="@+id/imageEditEvent"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/app_name"
                        android:padding="@dimen/d1dp"
                        android:src="@drawable/ico_edit_gray"/>

                </LinearLayout>


                <TextView android:id="@+id/textTargetHead"
                          android:layout_width="match_parent"
                          android:layout_height="0dp"
                          android:layout_marginTop="@dimen/d3dp"
                          android:layout_weight="1"
                          android:alpha="0.8"
                          android:ellipsize="end"
                          android:gravity="center_vertical"
                          android:maxLines="2"
                          android:textColor="@color/colorActivityHeader"
                          android:textSize="@dimen/d11sp"/>



            </LinearLayout>

        </LinearLayout>


    </android.support.v7.widget.CardView>


<TextView
    android:id="@+id/textDate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:gravity="center"
    android:maxLines="2"
    android:textSize="@dimen/d11sp"/>

现在,由于我需要在画布中绘制长路径,我在“Srollview”中设置了layertype=Software,这样我的视图可以平滑地滚动。

但是当我使用此属性时,Cardview不会设置角点半径海拔。如果从Scrollview中删除此属性,那么它可以工作,但我的视图滞后。

有人能帮我解决这个问题吗?

共有1个答案

尚鸿才
2023-03-14

这是我从Android开源项目-问题跟踪程序中得到的

仅硬件渲染支持阴影。

除此之外,

如果您的应用程序仅使用标准视图,我认为启用硬件加速不会有太大影响。

阅读此处,了解何时使用或不使用硬件加速
阅读有关硬件加速工作原理的更多信息!

 类似资料:
  • 我有一个回收站视图,用于显示项目列表。有这个android CardView类由android给出,以显示卡片布局。如果我使用相对布局并将其背景设置为白色,它的工作方式相同。此外,在CardView的情况下,我必须无论如何添加一个儿童布局,基本上包含卡内的所有视图。所以我想知道使用CardView(实际上增加了视图的层次结构)而不是直接使用普通的Layout是否有任何好处。

  • 最小SDK为21。当我点击回收器适配器中的cardview时,不会产生连锁反应,只会进入下一个屏幕。recyclerview位于片段内部。 适配器代码,其中我对每个项目进行了onClick。

  • 以下是CardView的XML代码: 我尝试对ImageView(和LinearLayout)的属性使用wrap_content,并尝试包含属性android: caleType="fitXY",但它没有帮助,似乎没有任何效果。 谁能帮我一下吗?我非常感谢您的每一句评论,也非常感谢您的帮助。

  • NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat

  • 在实现并尝试将动画应用于箭头文本视图后,当单击箭头时,动画显示异常行为。如何修复动画并获得与预期动画图像相似的结果? 预期动画 当前动画 回收视图项目 MyRecyclerAdapter。JAVA 苏拉布的建议

  • 问题内容: 我的Dockerfile位于文件夹的根目录中,包含在主包中。 看起来如下: 我收到以下错误: 我究竟做错了什么?码头工人完成后可以登录命令吗? 问题答案: 您正在将所有文件复制到Image根目录,未安装任何依赖项,尝试构建它,然后从运行二进制文件。该目录中不存在二进制文件,并且正在生成错误。 我建议使用这样的Dockerfile, 这将执行以下操作。 将项目文件复制到。 将工作目录设置