TextView:仅在预览中显示文本,在运行时不显示
TextView: display text in preview only, not during runtime
有没有办法在 Android studio 中的预览窗格中显示文本,而在 phone 中 运行 时却不在实际应用程序中显示?
我目前使用 android:hint
属性,这对于查看 space 一个 TextView
需要多少或文本的大小非常有用。
但是,问题是如果没有文本分配给 TextView
,提示会显示在应用程序中。
有没有办法让文本仅在 android studio 中显示而不在运行时显示?
是tools:text="some text"
。这仅在 Android Studio 中可见。
来自docs:
You can insert sample data in your layout preview by using the tools: prefix instead of android: with any attribute from the Android framework. This is useful when the attribute's value isn't populated until runtime but you want to see the effect beforehand, in the layout preview.
For example, if the android:text attribute value is set at runtime or you want to see the layout with a value different than the default, you can add tools:text to specify some text for the layout preview only.
有没有办法在 Android studio 中的预览窗格中显示文本,而在 phone 中 运行 时却不在实际应用程序中显示?
我目前使用 android:hint
属性,这对于查看 space 一个 TextView
需要多少或文本的大小非常有用。
但是,问题是如果没有文本分配给 TextView
,提示会显示在应用程序中。
有没有办法让文本仅在 android studio 中显示而不在运行时显示?
是tools:text="some text"
。这仅在 Android Studio 中可见。
来自docs:
You can insert sample data in your layout preview by using the tools: prefix instead of android: with any attribute from the Android framework. This is useful when the attribute's value isn't populated until runtime but you want to see the effect beforehand, in the layout preview.
For example, if the android:text attribute value is set at runtime or you want to see the layout with a value different than the default, you can add tools:text to specify some text for the layout preview only.