【问题标题】:CardView does not show elevation at run timeCardView 在运行时不显示海拔
【发布时间】:2017-06-11 22:10:49
【问题描述】:

这里是xml代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.himanshu.staticlogin.MainActivity"
android:weightSum="1">
<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    card_view:cardBackgroundColor="@color/cardview_dark_background"
    card_view:cardElevation="10dp"
    android:clickable="true"
    />
</LinearLayout>

它在预览中显示高度,但当我运行文件时它没有。我做错了什么?

【问题讨论】:

  • 您使用的是什么版本的设备?
  • 我最近在 SDK 的 v23 上遇到并解决了同样的问题。如果您显示清单文件的应用程序标签,那么我可能会给您解决方案。

标签: java android xml eclipse android-studio


【解决方案1】:

为卡片视图设置:

card_view:cardUseCompatPadding="true"

【讨论】:

    【解决方案2】:

    在您的 xml 中使用 card_view:cardUseCompatPadding="true" 以显示前 Lollipop 机器人的高度。

    【讨论】:

      猜你喜欢
      • 2021-07-19
      • 2018-01-13
      • 2023-03-06
      • 1970-01-01
      • 2015-08-22
      • 2015-02-13
      • 2015-02-14
      • 2019-03-23
      • 2016-11-11
      相关资源
      最近更新 更多