您现在的位置: 主页 > 嵌入式操作系统 > Android > 安卓开发实用技巧:TextView预览
本文所属标签:
为本文创立个标签吧:

安卓开发实用技巧:TextView预览

来源:android 网络用户发布,如有版权联系网管删除 2018-08-22 

背景:

使用TextView时,为了方便在开发工具中预览效果,需要在TextView中设置文字(如:android:text="Hello World"),但是等到后面提交时,为了避免显示这样默认的信息,通常需要把这个删除掉。但是删除后,后续就无法预览TextView了,为开发带来不便。

目标:

既做到可以预览,又不影响TextView的默认显示。

解决方案:

1. 引入命名空间:xmlns:tools="http://schemas.android.com/tools"

2. 为TextView设置:tools:text="Hello World"

样例:

<LinearLayout 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">    <TextView        android:id="@+id/textView"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_weight="1"        tools:text="Hello World"        android:textSize="60sp" />LinearLayout>

点击下载样例



              查看评论 回复



嵌入式交流网主页 > 嵌入式操作系统 > Android > 安卓开发实用技巧:TextView预览
 显示 预览 但是

"安卓开发实用技巧:TextView预览"的相关文章

网站地图

围观()