【问题标题】:Is there way to ignore Ids generated to Binding class有没有办法忽略生成到 Binding 类的 Id
【发布时间】:2021-07-17 02:45:54
【问题描述】:

在使用带有 ConstraintLayout 的 viewBinding 时,可能会创建很多 Id 来帮助描述视图关系,但在 Kotlin/Java 中永远不会使用。

我刚刚发现了两个有用的工具属性

  1. tools:viewBindingIgnore="true" 用于防止在 Binding 中生成整个布局,但不适用于单个 Id。
  2. tools:viewBindingType="TextView" 用于更改 Binding 中生成的 Type。

那么有什么方法可以忽略 ID 吗?我不想让它们污染 Kotlin/Java。

【问题讨论】:

    标签: android-viewbinding


    【解决方案1】:

    目前,没有办法在逐个视图的基础上忽略视图绑定生成。如果您使用 Proguard,则未使用的 ViewBinding ID 将从最终 APK 中删除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-02
      • 2015-04-17
      • 1970-01-01
      • 2020-02-11
      • 2017-04-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-27
      相关资源
      最近更新 更多