[英]ImageView not showing in phone but showing in Android Studio
My issue is that, when I add an ImageView using the "Pick a Resource" tool, the image is shown in the layout of the activity in Android Studio.我的问题是,当我使用“选择资源”工具添加 ImageView 时,图像显示在 Android Studio 中的活动布局中。 but when I execute it on my phone which is Huawei Y7 Prime .
但是当我在华为 Y7 Prime手机上执行它时。 It doesn't show at all.
它根本不显示。
I tried many solutions that are proposed in other questions step by step but any of them didn't seem to work.我逐步尝试了许多其他问题中提出的解决方案,但其中任何一个似乎都不起作用。
android.support.v7.widget.AppCompatImageView
instead of ImageView
but it seems that the android studio doesn't recognize it.android.support.v7.widget.AppCompatImageView
而不是ImageView
但似乎 android 工作室无法识别它。 I set all steps in this question ... But -> not working..android:src
instead of app:srcCompat
like it says in this one -> not working..android:src
而不是app:srcCompat
就像它在这个中所说的那样-> 不工作..android:hardwareAccelerated="false"
in AndroidManifest.xml file in the Application tag -> not working either..android:hardwareAccelerated="false"
-> 也不起作用..src
instead of srcCompat
like this onesrc
而不是srcCompat
I used a very basic code to set the ImageView我使用了一个非常基本的代码来设置 ImageView
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:srcCompat="@tools:sample/backgrounds/scenic" />
I Used The LayoutInspector tool to see if the image is showing.我使用了 LayoutInspector 工具来查看图像是否正在显示。 I found that it's not.
我发现它不是。
Please Anyone can help??请问有人可以帮忙吗??
Instead of using tools:srcCompat
, you should use android:src
.而不是使用
tools:srcCompat
,您应该使用android:src
。
The tools
namespace is used for debug purposes, that's why it's visible in AndroidStudio but not in actual device. tools
命名空间用于调试目的,这就是它在 AndroidStudio 中可见但在实际设备中不可见的原因。
Also, make sure your source uses the valid reference (or one from android).另外,请确保您的来源使用有效的参考(或来自 android 的参考)。 For example:
例如:
android:src="@drawable/your_image"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.