同时创建 TextView 和 Buttons 时,当资源设置为文本时
tools:text="@string/testString"
它将显示在 XML 的设计 View 中,但是在运行应用程序时,按钮或文本显示硬编码文本中的值,如果它们不存在则显示为空白。
android:text="Something else"
但是,strings.xml 资源是可读的,因为更改标题 View 的应用程序名称是有效的。
到目前为止,这发生在每个 Android Activity 中,即使是在全新的项目中。我已尝试卸载并重新安装工作室和所有 APK。
最佳答案
tools名称前缀仅作为 android studio 布局设计器中隐含的名称起作用,对应用程序没有影响。
所以你应该使用android:text="@string/testString"
关于Android Studio : String resources showing in design view, 不在模拟器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43333887/