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

等属性。

相关推荐
来来走走1 小时前
kotlin学习 lambda编程
android·学习·kotlin
无知的前端1 小时前
一文精通-Kotlin中双冒号:: 语法使用
android·kotlin
Andy2 小时前
Mysql基础2
android·数据库·mysql
下位子3 小时前
『OpenGL学习滤镜相机』- Day1: OpenGL ES 入门与环境搭建
android·opengl
正经教主3 小时前
【问题】Android Studio专用C盘空间过大问题:迁移相关程序文件
android·android studio
下位子3 小时前
『OpenGL学习』 从零打造 Android 滤镜相机
android·opengl
●VON3 小时前
双非大学生自学鸿蒙5.0零基础入门到项目实战 - 歌曲列表
android·华为·harmonyos
dessler4 小时前
MYSQL-多种方法安装部署
android·mysql·adb
凛_Lin~~6 小时前
安卓接入Twitter三方登录
android·java·twitter
.豆鲨包7 小时前
【Android】Lottie - 实现炫酷的Android导航栏动画
android·java