Chr*_*ght 29 android graphical-layout-editor
我有一个样式的TextView,它的真实文本在运行时动态填充.图形布局视图对于了解此组件在外观和感觉等方面与其他组件的工作方式非常有用.此文本字段没有合理的默认值,我希望在填充之前它是空白的.如果我没有在TextView声明中指定任何文本,则TextView为空.我可以使用以下方法手动设置文本:
<TextView
...
android:text="Preview text"/>
Run Code Online (Sandbox Code Playgroud)
然后切换到图形布局.但是,我必须记住要删除它,否则冒着生产版本的风险.
有没有办法指定仅在图形布局预览中看到但在运行时不适用的文本?
编辑:我正在使用Eclipse ADT.
Kuf*_*ffs 62
是的,您可以使用Android Studio中的设计工具扩展属性.
请参阅此页面https://developer.android.com/studio/write/tool-attributes.html
基本上你定义工具命名空间
xmlns:tools="http://schemas.android.com/tools"
Run Code Online (Sandbox Code Playgroud)
然后使用它来设置占位符文本.
<EditText
tools:text="John Doe"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
这实际上适用于大多数(如果不是所有xml属性).
例如
tools:visibility="gone"
Run Code Online (Sandbox Code Playgroud)
将预览可见性设置为"已消失",但运行时可见性将保持不变.
| 归档时间: |
|
| 查看次数: |
6138 次 |
| 最近记录: |