在 Android Studio 中,XML 布局中视图 ID 的“查找用法”操作不适用于 Android 视图绑定

Ale*_*Wih 11 android android-studio android-viewbinding

Android 中的View Binding被大力提倡作为findViewById()Kotlin 扩展甚至是 Kotlin 扩展的更好替代品,但由于某种原因,最基本的功能,如View在 Android Studio 的布局编辑器中按其 ID搜索 a的用法不起作用。

即使在官方 Ach 组件示例存储库中的视图绑定示例中,它也不起作用。
我们这里有:

  1. XML布局fragment_blank.xml具有TextView与IDtextViewFragment如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".InflateFragment">

    <TextView
        android:id="@+id/textViewFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/hello_blank_fragment" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
  1. 使用视图绑定InflateFragment.kt将文本设置为此的片段TextView
override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        val binding = FragmentBlankBinding.inflate(inflater, container, false)
        fragmentBlankBinding = binding
        binding.textViewFragment.text = getString(R.string.hello_from_vb_inflatefragment)
        return binding.root
    }
Run Code Online (Sandbox Code Playgroud)
  1. 因此,当我在布局编辑器中选择此 ID 并从上下文菜单中执行“查找用法”操作时: 在此处输入图片说明

  2. 实际上什么也没找到,但我们清楚地看到我们正在为这个文本视图设置文本 InflateFragment.kt 在此处输入图片说明

关于如何View从布局编辑器中通过ID搜索此类用法的任何想法?
无法相信视图绑定缺少这样的基本功能。

Android Studio 版本4.0.1
摇篮版6.6.1
Android Gradle 插件版4.0.1