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=""

等属性。

相关推荐
雮尘2 小时前
手把手带你玩转Android gRPC:一篇搞定原理、配置与客户端开发
android·前端·grpc
ktl4 小时前
Android 编译加速/优化 80%:一个文件搞定,零侵入零配置
android
alexhilton15 小时前
使用FunctionGemma进行设备端函数调用
android·kotlin·android jetpack
冬奇Lab18 小时前
InputManagerService:输入事件分发与ANR机制
android·源码阅读
张小潇20 小时前
AOSP15 Input专题InputManager源码分析
android·操作系统
RdoZam1 天前
Android-封装基类Activity\Fragment,从0到1记录
android·kotlin
奥陌陌1 天前
android 打印函数调用堆栈
android
用户985120035831 天前
Compose Navigation 3 深度解析(二):基础用法
android·android jetpack
恋猫de小郭1 天前
Android 官方正式官宣 AI 支持 AppFunctions ,Android 官方 MCP 和系统级 OpenClaw 雏形
android·前端·flutter
黄林晴1 天前
Android 17 Beta 2,隐私这把锁又拧紧了
android