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

等属性。

相关推荐
hunterandroid30 分钟前
[Android 从零到一] Compose 动画实战:从 AnimatedVisibility 到复杂转场与手势联动
android
Knight_AL1 小时前
Lombok @Builder 踩坑:build() 前后对象类型不一样
android·java·开发语言
大黄说说1 小时前
Android 本地存储深度对比:SharedPreferences、MMKV、Room 数据库怎么选?
android·数据库
阿巴斯甜2 小时前
adb push .../AdapterService.apk 和 .../区别:
android
恋猫de小郭2 小时前
Flutter 的另外一种形态?社区 DartNative 要来了。
android·前端·flutter
我命由我123452 小时前
Android Drawable - gradient
android·java·java-ee·kotlin·android studio·android-studio·android runtime
Kapaseker3 小时前
AI 时代,读源码还有用吗?从 Kotlin 集合排序说起
android·kotlin
️学习的小王4 小时前
二级MySQL PHP综合应用题完整考点+历年真题风格练习题
android·mysql·php
YB137515 小时前
jetpack compose 副作用 SideEffect
android·kotlin
CHB17 小时前
uni-app x 蒸汽模式 性能测试基准报告 Benchmark【Android版】
android·ios·uni-app