【问题标题】:Update libraries to support AndroidX更新库以支持 AndroidX
【发布时间】:2018-10-14 13:49:58
【问题描述】:

目前我正在更新我的项目以支持 AndroidX。 我已将所有库重构为新的 androidx- 库。 尽管如此,仍然存在一些依赖项,例如 com.wdullaer:materialdatetimepicker,它们不会被更新,并且会以一种在 UI 中看起来非常难看的方式显示。

如何强制这些按钮使用新的材质库? 我已启用选项

android.useAndroidX=true
android.enableJetifier=true

但如前所述,它不会影响这些库。

【问题讨论】:

    标签: android-support-library androidx


    【解决方案1】:

    答案可以很简单:

    Material Components 将 Button 的所有实例替换为一个实例 使用其常规主题之一时的 MaterialButton: https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md#material-components-themes MaterialButton 的默认版本使用 colorPrimary 作为 背景颜色。因为 Material Components 取代了 View 用他们自己的实现替换我无能为力 从此库中修复此问题。

    有两种解决方法:

    使用桥主题之一,它不会取代 View Inflater 通过添加在您的应用程序主题中再次覆盖 View inflater 您的应用程序主题中的以下语句:androidx.appcompat.app.AppCompatViewInflater 然后,您需要在您的 应用程序而不是按钮

    所以您基本上要做的就是将这一行添加到您的应用程序主题中。然后,材料组件将不再被替换。瞧!

    <item> name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item>
    

    参考https://github.com/wdullaer/MaterialDateTimePicker

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-20
      • 1970-01-01
      • 1970-01-01
      • 2020-04-23
      • 2018-12-13
      相关资源
      最近更新 更多