zoukankan      html  css  js  c++  java
  • 安卓开发实用技巧:TextView预览

    背景:

         使用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>

     点击下载样例

     
     
  • 相关阅读:
    闭包和this
    闭包与变量
    闭包
    ES6扩展运算符的几个小技巧
    js对象的深拷贝
    js获取当前点击元素的索引
    前端学习指北
    css实现心形图案
    this 知多少
    js数字进制转换
  • 原文地址:https://www.cnblogs.com/cxyzy/p/9509700.html
Copyright © 2011-2022 走看看