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

等属性。

相关推荐
YF02112 小时前
深入剖析 Kotlin 的高效之道与核心实战
android·kotlin·app
程序员码歌2 小时前
别再让 AI 自由发挥了:OpenSpec 才是团队协作不跑偏的关键
android·前端·人工智能
敲代码的鱼3 小时前
NFC读卡能力 支持安卓/iOS/鸿蒙 UTS插件
android·ios·uni-app
刮风那天3 小时前
Android 常驻进程如何被查杀?
android
刮风那天4 小时前
Android 如何降低进程优先级可以被查杀?
android
资源分享助手6 小时前
超级改图P图改字无限制版教程(安卓)AI改图软件、图片改字软件、安卓修图APP、智能消除工具、图片拼接APP、超级改图下载
android·人工智能
Lehjy6 小时前
【Linux】文件系统磁盘存储结构
android·linux·运维
BU摆烂会噶7 小时前
【LangGraph】节点内调用与状态隔离
android·人工智能·python·ui·langchain·人机交互
BU摆烂会噶8 小时前
【LangGraph】作为节点添加与状态共享
android·人工智能·python·ui·langchain·人机交互
刘大猫.9 小时前
重塑经典:Snapseed4.0全面登陆安卓,内置“胶片相机”与专业手动模式
android·数码相机·ai·机器人·大模型·算力·snapseed4.0