Android “中的图像预览”;“设计模式”;在尚未以编程方式设置的视图上
我想知道是否有一个xml标记,它允许我在Android “中的图像预览”;“设计模式”;在尚未以编程方式设置的视图上,android,xml,button,imageview,Android,Xml,Button,Imageview,我想知道是否有一个xml标记,它允许我在ImageViews和/或按钮s的设计模式下查看图像的预览(因此无需实际使用app:srcCompat或android:background) 这是因为我将在java文件中以编程方式设置真实图像 举个例子,我指的是类似tool:text的TextView: <TextView android:id="@+id/text_view" android:layout_width="match_parent" android:layo
ImageView
s和/或按钮
s的设计模式下查看图像的预览(因此无需实际使用app:srcCompat
或android:background
)
这是因为我将在java文件中以编程方式设置真实图像
举个例子,我指的是类似tool:text
的TextView
:
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tool:text="Here will be displayed some text" />
您可以使用
工具
命名空间anywhere在预览模式下应用xml属性值
下面是一个例子:
<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:src="@drawable/common_google_signin_btn_text_dark_pressed"/>
</LinearLayout>
您可以在预览模式下查看图像。谢谢您的回答!我刚刚将
tools:src=“@drawable/my_icon”
添加到ImageView
和xmlns:tools=”http://schemas.android.com/tools“
到根LinearLayout
但它不工作:(它不会给出任何错误,尽管您的视图可能在布局外部绘制?您可以共享布局文件吗?”?