【问题标题】:CardView cardCornerRadius is not displayed on real deviceCardView cardCornerRadius 在真实设备上不显示
【发布时间】:2023-01-18 15:15:34
【问题描述】:

我在 CardView 中显示 cardCornerRadius 时遇到一点问题。在模拟器上一切正常,但一旦我在真实设备上测试应用程序,我就再也看不到 CardView 周围的圆角半径。可能是什么原因 ? API 级模拟器 28 (PIE)

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="10dp">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="20dp"
        app:cardCornerRadius="20dp"
        >
    
     ... 
  </LinearLayout>

移动视图:

模拟器视图:

【问题讨论】:

  • 手机图片截图
  • 将卡片视图置于线性布局之外
  • this。您的问题的解决方案就在这里。
  • 但我需要 LinearLayout...
  • 你能解释一下你的 XML 代码吗,你有 wrap_content 有一个高度,为什么它不添加和显示角半径

标签: android android-studio android-design-library android-developer-api


【解决方案1】:

如果您在清单中使用 android:hardwareAccelerated="false",请尝试此操作,然后删除此行,因为此行会阻止卡片视图显示半径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-07
    相关资源
    最近更新 更多