- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在屏幕截图中,您可以看到有四个重叠的 CardView
,但顶部和右侧的角阴影没有显示在前面的卡片上,(仅显示最后一张卡片的阴影)
更新:下面 Lollipop 影子正在工作
下面是一个 CardView
的 XML 代码,我以编程方式膨胀这些 CardView 布局,并设置 XY 属性以实现重叠 View
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/offer_card_width"
android:layout_height="97dp"
app:cardBackgroundColor="@color/windowBackgroundSecondary"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
<RelativeLayout
android:padding="@dimen/padding_regular"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/icon_offer"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/bg_circular_offer"
android:padding="8dp"
android:src="@drawable/ic_content_copy" />
<TextView
android:layout_marginLeft="@dimen/margin_regular"
android:id="@+id/text_offer_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/icon_offer"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/submit_button"
android:textSize="@dimen/text_size_regular"
android:text="Some content will be there" />
<TextView
android:id="@+id/text_offer_desc"
android:layout_marginTop="@dimen/margin_medium"
android:layout_marginLeft="@dimen/margin_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_offer_title"
android:layout_toRightOf="@+id/icon_offer"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="@dimen/text_size_small"
android:text="Some content will be there, Some content will be there" />
<LinearLayout
android:layout_marginLeft="@dimen/margin_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/icon_offer"
android:orientation="horizontal">
<TextView
android:textColor="#6f6f6f"
android:textSize="@dimen/text_size_regular"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Code:" />
<TextView
android:id="@+id/text_copy_code"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/padding_medium"
android:ellipsize="end"
android:maxLines="1"
android:drawableRight="@drawable/ic_content_copy"
android:textColor="@color/label_header_opac"
android:textSize="@dimen/text_size_regular"
android:text="TEST2016" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
下面是用于扩充 cardview 布局的 java 代码
private void setupUi() {
CardView cardView;
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
frameLayout = (FrameLayout) findViewById(R.id.container_pager_offer);
frameLayout.removeAllViews();
CardView.LayoutParams params;
int cardMargin = (int) getResources().getDimension(R.dimen.offer_card_overlapping);
int sideMargin = (int) getResources().getDimension(R.dimen.margin_semi_large);
for (int i = 0; i < 4; i++) {
cardView = (CardView) inflater.inflate(R.layout.card_offer_for_pager, null);
TextView textView = (TextView) cardView.findViewById(R.id.text_copy_code);
CommonUtils.setIconColor(textView, 2, R.color.label_header_opac);
params = new CardView.LayoutParams((int) getResources().getDimension(R.dimen.offer_card_width),
(int) getResources().getDimension(R.dimen.offer_card_height));
cardView.setX(cardMargin * ( 4 - i ) + sideMargin); //XCOORD
cardView.setY(cardMargin * ( i + 1 )); //YCOORD
cardView.setLayoutParams(params);
frameLayout.addView(cardView);
}
}
最佳答案
我已经找到了一个简单的答案,
请为 CardView 添加一个父布局,这个父布局可以是 LinearLayout
或 RelativeLayout
,并为父布局提供透明背景,这样就可以了
下面是例子
<LinearLayout 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="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/mdtp_circle_color"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>
</LinearLayout >
关于android - CardView 阴影不显示,如果不止一张卡片相互重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39011972/
让我们开始吧,3 个类(Card、Start、Deckofcards) 1° 卡: public class Card { private String type; private i
我要创建一个二十一点游戏,我正在尝试弄清楚如何发牌并让它显示值和名称。我选择两个属性的原因纯粹是基于逻辑,当涉及到将 A 视为 1 或 11 时。还没有达到这一点,只是想如果有人想知道的话我会包括在内
我正在尝试使用 twitter 元标记(以及 Facebook 等其他网站的 Open Graph)创建 Twitter 卡片。当我看到来自其他人(例如 NPR 新闻)的推特提要时,卡片会默认展开。
我正在开发一个玩基本扑克游戏的程序,但这并不重要。我有一组 52 张牌,包含花色和等级。我想打印 4 行 13 行的值(花色和等级)。这可能是一个简单的问题,但我整天都在努力解决这个问题。因此,我非常
我开发了一个包含三列(两列相等,一列较小)的网格。我的问题是我无法在卡片上设置高度,我在 px 中使用了它们并且它起作用了,但这不是最好的方法。我希望这三列具有相同的高度(页面的 100%)并且一些卡
我在 4 个不同的列中开发了 4 个 Bootstrap 卡。在每张卡片中,我创建了一张包含某种类型信息的新卡片。 我的问题是,当我缩小屏幕尺寸(响应测试)时,文本会从卡片中溢出。我的问题是什么,我该
我怎样才能达到 固定高度 具有垂直可滚动 的 bootstrap 4 卡卡片文字部分? Card title This portion and
在我的程序中,我有一个大 Canvas ,我在其中提取多个选定区域并将这些区域绘制到单独的新小 Canvas 上。 我想使用此 API 将新创建的 Canvas 作为附件发布到 trello POST
我想在卡片 View 中显示联系信息,如果需要,应该调整卡片 View 的大小以包含所有信息。 这是布局部分: 但是 an
这是我的card_view。我已经提到了 card_view:cardElevation。但是仍然没有显示阴影。 我搜索了很多链接。他们在任何地方都提到要使用 card_view:cardElevat
我正在使用此处的框架 - cardsui 如何在卡片顶部添加分享按钮。我已经使用点击方法在 xml 中实现了它,但是当我按下它时应用程序崩溃并说该方法不存在(是的,我将该方法添加到主 java 文件中
我正在将 cardview 与 recycler view 一起使用。但早些时候我使用相同的代码来做事没有任何问题。但现在我正在使用 fragment 。现在我得到卡片 View 之间的距离更大。我的
我的卡片 View 设置如下: android:layout_marginTop="2dp" android:layout_marginLeft="6dp" android:layout_margin
我正在制作一个二十一点游戏,并创建了一个数组来充当用户发牌的手牌。我希望能够对其进行排序,以便手按数字顺序排序,这样可以更简单地确定用户的手的类型。这是我的卡片结构: struct ACard{
我希望在一个运行在 Wordpress 上的网站上实现 Twitter Cards(关于 Twitter Cards 的文档在这里:https://dev.twitter.com/docs/cards
我需要帮助解决这个难题。在 bootstrap 4.1 中使用卡片列和卡片时,当我不想这样做时,行会中断。我将列数设置为 4,当有 4 张卡片时,它看起来很完美。当添加第五张牌时,它会将行分成顶部的
我有一个 android ListView ,它显示类似卡片的 View ,正如您在这张图片中看到的,我的卡片之间有一条灰色细线: 我怎样才能摆脱灰线? 我实现这个卡片 View 的xml是这样的:
我正在尝试添加带有回收站 View 的卡片 View 。但它没有显示任何内容,只是一个空白 View 。 我在这里看到了这方面的问题,它有为回收站 View 和卡片 View 添加依赖项的答案。这出现
我在 android 中通过回收站 View 实现卡片 View ,但我的卡片 View 没有显示。我正在使用自定义适配器将数据填充到卡片 View 。我已经尝试了所有方法,但没有显示卡片 View
在我的应用程序中,我有一个卡片 View ,其中包含一个 TextView 和一个按钮,该按钮最初是隐藏的,当单击卡片 View 时,会显示该按钮。我不知道如何在显示按钮时将其设置为动画。任何人都可以
我是一名优秀的程序员,十分优秀!