【问题标题】:?android:attr/selectableItemBackground` requires API level 11 (current min is 10)?android:attr/selectableItemBackground` 需要 API 级别 11(当前最小值为 10)
【发布时间】:2017-05-02 10:31:55
【问题描述】:

如果我在我的卡片视图中将其用作foreground,应用程序将在 API 10 之前崩溃。

    <android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_margin="@dimen/card_margin"
 //android:foreground="?android:attr/selectableItemBackground"
    android:elevation="3dp"
    card_view:cardCornerRadius="@dimen/card_album_radius">

我正在开发一个大约七个月的项目,直到现在我的应用程序在每个 API 级别上都可以工作。这迫使我提高我的最小 SDK。

你能帮我解决这个问题吗,我怎样才能绕过它。


临时答案

我在用这个

android:foreground="?attr/selectableItemBackground"

代替:

android:foreground="?android:attr/selectableItemBackground"

它是某种灰色 onClick 而不是蓝色,但我不太关心颜色,所以这将解决现在的崩溃问题

【问题讨论】:

  • 在 build.gradle 文件中将 min api 级别更改为 11。
  • 你真的支持 api 10 吗?
  • 它明确表示需要 API 级别 11(当前最低为 10)。您可以更改最低版本或为其寻找替代解决方案
  • @NongthonbamTonthoi API 10 对我很重要
  • @azizbekian 是的

标签: android android-xml android-cardview


【解决方案1】:

用户 android:foreground="?selectableItemBackgroundBorderless" 而不是 android:foreground="?android:attr/selectableItemBackground"

使用 ?attr:(或 ? 简写)而不是 ?android:attr 引用支持库,因此可返回到 API 7。

【讨论】:

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