jjzjj

Android 在 RelativeLayout 中将 Cardview 置于父 Cardview 之上

coder 2023-12-13 原文

如何在下面的屏幕截图中将 cardview 放在父级 cardview 之上?

当我将图像放入 CardView 时导致我的视​​图损坏

正确的观点必须是:

我的 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    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:background="@drawable/content_background">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/activity_main_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="65dp"
                    android:background="@color/colorPrimary"
                    android:titleTextColor="#ffffff">

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

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/icon_signal_robot"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginRight="10dp"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-android}"
                            android:textColor="@color/quote"
                            android:textSize="30sp"/>

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/icon_search_icon"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginRight="10dp"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-search}"
                            android:textColor="#ffffff"
                            android:textSize="25sp"/>

                        <com.gigamole.library.ntb.NavigationTabBar
                            android:id="@+id/market_detail_navigation_tab_bar"
                            android:layout_width="90dp"
                            android:layout_height="30dp"
                            android:layout_gravity="center_vertical|left"
                            android:background="@drawable/bg_round_circle"
                            app:ntb_active_color="#4527A0"
                            app:ntb_animation_duration="150"
                            app:ntb_corners_radius="50dp"
                            app:ntb_inactive_color="#dddfec"
                            app:ntb_preview_colors="@array/red_wine"/>

                        <TextView
                            android:id="@+id/signal_application_detail_activity_title"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:text="@string/app_name"
                            android:textColor="#ffffff"
                            android:textSize="19sp"/>

                        <ImageView
                            android:id="@+id/activity_main_hearing_status"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="10dp"
                            android:gravity="center|right"
                            android:src="@drawable/ic_antenna_white"/>

                    </LinearLayout>
                </android.support.v7.widget.Toolbar>
            </android.support.design.widget.AppBarLayout>

            <LinearLayout
                android:id="@+id/signal_loading_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:background="@color/colorPrimary"
                android:gravity="center"
                android:orientation="vertical"
                android:visibility="gone">

                <TextView
                    android:id="@+id/loading_view_title"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:gravity="center"
                    android:text="@string/app_name"
                    android:textColor="#FFF"
                    android:textSize="35sp"
                    />

                <TextView
                    android:id="@+id/loading_view_description"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:gravity="center"
                    android:text="@string/app_description"
                    android:textColor="#FFF"
                    android:textSize="18dp"
                    />

                <com.zl.reik.dilatingdotsprogressbar.DilatingDotsProgressBar
                    android:id="@+id/dots_progressBar"
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:color="#ffee00"
                    android:radius="4dp"
                    app:dd_animationDuration="300"
                    app:dd_horizontalSpacing="7dp"
                    app:dd_numDots="5"
                    app:dd_scaleMultiplier="1.5"
                    />
            </LinearLayout>

            <RelativeLayout
                android:id="@+id/frame"
                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:layout_gravity="center_vertical"
                android:background="@drawable/content_background">

                <android.support.v7.widget.CardView
                    android:id="@+id/malam"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:id="@+id/imageView2"
                        android:layout_width="match_parent"
                        android:layout_height="230dp"
                        android:scaleType="centerCrop"
                        android:src="@drawable/background"/>
                </android.support.v7.widget.CardView>


                <LinearLayout
                    android:id="@+id/linearLayout3"
                    android:layout_width="match_parent"
                    android:layout_height="180dp"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="120dp"
                    android:fitsSystemWindows="true"
                    android:orientation="vertical">

                    <android.support.v7.widget.CardView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        app:cardCornerRadius="0dp"
                        app:elevation="2dp">

                    </android.support.v7.widget.CardView>
                </LinearLayout>
                <ImageView
                    android:id="@+id/robot_dialog_icon"
                    android:layout_width="65dp"
                    android:layout_height="65dp"
                    android:layout_alignBottom="@+id/malam"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="75dp"
                    android:fitsSystemWindows="true"
                    android:src="@drawable/dialog_robot_dialog"
                    app:layout_collapseMode="parallax"/>
            </RelativeLayout>

        </LinearLayout>
    </android.support.design.widget.CoordinatorLayout>

</FrameLayout>

最佳答案

框架和协调器布局的工作方式相同:第一个 View 是最背景的,下一个 View 位于前一个的顶部。

所以我认为您应该在 xml 中更改 CardViews 的顺序。

您也可以尝试使用 android:elevation 以获得理想的结果。

经过一些尝试,我获得了 such result:

我的 xml 是:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/frame"
    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:layout_gravity="center_vertical"
    android:background="@color/colorAccent">

    <android.support.v7.widget.CardView
        android:id="@+id/malam"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="230dp"
            android:scaleType="centerCrop"
            android:background="@android:color/holo_blue_dark"/>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/white_card"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="120dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        app:cardCornerRadius="0dp"
        app:elevation="10dp">
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="65dp"
        android:layout_height="65dp"
        android:translationY="32dp"
        app:layout_anchor="@id/white_card"
        app:layout_anchorGravity="center_horizontal"
        android:layout_gravity="center_horizontal">
    <ImageView
        android:id="@+id/robot_dialog_icon"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorPrimary"/>
    </android.support.v7.widget.CardView>

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

关于Android 在 RelativeLayout 中将 Cardview 置于父 Cardview 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38262795/

有关Android 在 RelativeLayout 中将 Cardview 置于父 Cardview 之上的更多相关文章

  1. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  2. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  3. ruby - 在 Ruby 中将整数格式化为固定长度的字符串 - 2

    有没有一种简单的方法可以将给定的整数格式化为具有固定长度和前导零的字符串?#convertnumberstostringsoffixedlength3[1,12,123,1234].map{|e|???}=>["001","012","123","234"]我找到了解决方案,但也许还有更聪明的方法。format('%03d',e)[-3..-1] 最佳答案 如何使用%1000而不是进行字符串操作来获取最后三位数字?[1,12,123,1234].map{|e|format('%03d',e%1000)}更新:根据theTinMan的

  4. ruby - 无法在 Ruby 中将 ffmpeg 作为子进程运行 - 2

    我正在尝试使用以下代码通过将ffmpeg实用程序作为子进程运行并获取其输出并解析它来确定视频分辨率:IO.popen'ffmpeg-i'+path_to_filedo|ffmpegIO|#myparsegoeshereend...但是ffmpeg输出仍然连接到标准输出并且ffmepgIO.readlines是空的。ffmpeg实用程序是否需要一些特殊处理?或者还有其他方法可以获得ffmpeg输出吗?我在WinXP和FedoraLinux下测试了这段代码-结果是一样的。 最佳答案 要跟进mouviciel的评论,您需要使用类似pope

  5. ruby - 如何在 Ruby 中将负整数转换为二进制 - 2

    问题1:我无法通过以下方式找到将负整数转换为二进制的方法。我应该像这样转换它。-3=>"11111111111111111111111111111101"我在下面试过:sprintf('%b',-3)=>"..101"#..appearsanddoesnotshow111111bit.-3.to_s(2)=>"-11"#Thisjustadds-tothebinaryofthepositiveinteger3.问题2:有趣的是,如果我使用在线转换器,它告诉我-3的二进制是“0010110100110011”。"11111111111111111111111111111101"和"001

  6. ruby - 在 Ruby 中将转义的 unicode (\u008E) 转换为重音字符 (Ž)? - 2

    我遇到了一个非常困难的时期:#containedwithin:"MA\u008EEIKIAI"#shouldbe"MAŽEIKIAI"#natureofstring$pstring3"MA\u008EEIKIAI"$putsstring3MAEIKIAI$string3.inspect"\"MA\\u008EEIKIAI\""$string3.bytes#关于从哪里开始的任何想法?注意:这不是我的previousquestion的副本. 最佳答案 \u008E表示代码点为8e(十六进制)的unicode字符出现在字符串中的那个位置。

  7. arrays - 如何在下面的示例中将两个值数组分组为 n 个值数组? - 2

    我已经有很多两个值数组,例如下面的例子ary=[[1,2],[2,3],[1,3],[4,5],[5,6],[4,7],[7,8],[4,8]]我想把它们分组到[1,2,3],[4,5],[5,6],[4,7,8]因为意思是1和2有关系,2和3有关系,1和3有关系,所以1,2,3都有关系我如何通过ruby​​库或任何算法来做到这一点? 最佳答案 这是基本Bron–Kerboschalgorithm的Ruby实现:classGraphdefinitialize(edges)@edges=edgesenddeffind_maximum_

  8. ruby - 如何在 Ruby 中将变量用作变量名? - 2

    我怎样才能使下面的代码工作,以便两个puts都显示1?video=[]name="video"name[0]=1putsname[0]#givesme1putsvideo[0]#givesmenil 最佳答案 您可以使用eval使其工作:eval"#{name}[0]=1"不过我强烈反对这样做。在大多数情况下,你认为你需要做类似的事情,你应该使用HashMap。喜欢:context={"video"=>[]}name="video"context[name][0]=1 关于ruby-如何

  9. ruby-on-rails - 如何在 Ruby on Rails 中将数组持久保存到数据库? - 2

    我正在尝试将一个数组的数组保存到我在Rails中的SQLite数据库中。现在,我有一个可以容纳这样一个数组的对象,并且实例似乎可以毫无问题地保存。但是,它显然没有保存到数据库中——当我在与创建数组的View不同的View中调用My_Object.array上的函数时,结果为nil并且不起作用。例如:classMy_Object当我调用My_Object.new(:array=>[[1,2,3],[4,5,6]])时,一切似乎都正常工作,但我不能在其他任何地方访问:array属性,结果都是nil。有什么想法吗? 最佳答案 首先在您的表

  10. ruby - 在 Ruby 中将哈希值转换为另一个哈希值 - 2

    我有一个字符串散列navigable_objects={'Dashboard'=>root_path,'Timesheets'=>timesheets_path,'Clients'=>clients_path,'Projects'=>projects_path,}我想将它们转换成另一个散列,其中键又是键,但值是字符串“active”或空字符串,具体取决于当前Controller名称是否包含键。例如,假设当前Controller名称是“ClientsController”。我应该得到的结果是:{'Dashboard'=>'','Timesheets'=>'','Clients'=>'ac

随机推荐