Android 在布局中tools使用

效果图

布局

java 复制代码
 <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="你好,这是TextView"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:visibility="visible" />

    <ImageView
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv"
        tools:src="@mipmap/cn" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:background="@mipmap/cn"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/iv" />

在布局中因为各种原因,有时想让控件不显示,或者显示占位图的话,可以使用

java 复制代码
tools:src="@mipmap/cn"
tools:visibility="visible"
tools:text=""

等属性。

相关推荐
三少爷的鞋3 小时前
为什么成熟 Android 项目几乎看不到 IdleHandler?
android
kururunga4 小时前
Android知识点回顾之蓝牙协议
android·蓝牙·车载开发
StarsGreen5 小时前
aosp中的SELinux 策略配置和编译流程
android
方白羽9 小时前
Android 开发中常见的编译加速方案
android·app·gradle
StarsGreen11 小时前
Android VINTF 中 Device Manifest 与 Framework Manifest 详解
android
Name_NaN_None13 小时前
安卓手机远程控制电脑方法(Android/Windows) —— 「小白教程」
android·windows·智能手机·电脑·笔记本
恋猫de小郭13 小时前
Flutter Perfetto:Dart Heap Sampling 终于要接入 Android 原生内存分析了
android·前端·flutter
敢敢のwings1 天前
GR00T 2:当机器人学会先想象未来,再决定怎么动
android·机器人
传奇开心果编程1 天前
【Jetpack Compose娓娓道来】第55课:传感器与设备姿态——把物理世界的数据接进Compose
android·kotlin·移动开发·传感器·jetpack compose·ui框架·声明式ui
传奇开心果编程1 天前
【Jetpack Compose娓娓道来】第52课:蓝牙与位置权限——把“附近”和“在哪”安全地接进Compose
android·kotlin·移动开发·蓝牙·jetpack compose·声明式ui·位置权限