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>

     点击下载样例

     
     
  • 相关阅读:
    meta标签
    Vue(day8)
    Vue(day7)
    Vue(day6)
    Flex布局
    Vue(day5)
    jquery.data()&jquery.extend()
    Promise对象
    Vue(day4)
    Vue(day3)
  • 原文地址:https://www.cnblogs.com/cxyzy/p/9509700.html
Copyright © 2011-2022 走看看