Android中是否有ImageView内容的工具属性?
我找不到工具属性来设置Android布局中的示例图像。我的假设是,目前没有这样的事情,至少没有直接的支持 但我想知道我是不是搜索得不够好,或者是否有解决办法 如何在Android中使用工具在设计时定义图像占位符Android中是否有ImageView内容的工具属性?,android,android-layout,Android,Android Layout,我找不到工具属性来设置Android布局中的示例图像。我的假设是,目前没有这样的事情,至少没有直接的支持 但我想知道我是不是搜索得不够好,或者是否有解决办法 如何在Android中使用工具在设计时定义图像占位符 文本视图的工具属性示例(即文本的工具:文本属性): 这就像文本视图一样简单。只需使用tools:src设置图像 <ImageView android:layout_width="wrap_content" android:layout_height="wrap_c
文本视图的工具属性示例(即文本的工具:文本属性):
这就像
文本视图一样简单。只需使用tools:src
设置图像
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/placeholder" />
工具:背景也适合我
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:background="@mipmap/ic_launcher"/>
</LinearLayout>
提示:
在布局XML的根目录上写入toolNS
或tools
,然后使用“ALT+ENTER”完成此处的名称空间语句。同样适用于appNS,如果您使用new-->布局资源
生成布局,则默认情况下会提到android NS
链接中没有记录许多属性,但是这些属性与使用androidNS(android:)为当前视图或布局标记声明的属性相同
快乐编码:-)对随机真实样本图像使用此选项:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
tools:src="@tools:sample/backgrounds/scenic" />
我们仅在设计部分使用此选项,是否可以查看?我没有用过,这就是为什么我问是的,这就是tools
的用途。我想我们在整个项目中都在使用它。在许多用例中都有帮助。
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
tools:src="@tools:sample/backgrounds/scenic" />