为什么ImageView在Android Studio中显示通用图像而不是在设备上正常显示的请求图像?

问题描述

相关的xml代码

    <LinearLayout
        android:layout_width="409dp"
        android:layout_height="579dp"
        android:orientation="vertical"
        app:layout_constraintTop_toBottomOf="@+id/title_top"
        app:layout_constraintBottom_toTopOf="@id/title_bottom"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:gravity="center_horizontal"
        tools:layout_editor_absoluteX="1dp">

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toTopOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            android:src="@drawable/elenas_shepherd"
            app:layout_constraintLeft_toLeftOf="parent"
            android:contentDescription="@string/splash_description"
            />

    </LinearLayout>

(我只包括内部布局和ImageView;如果需要,我可以包括更多内容。)

图像“ elenas_shepherd”看起来像牧羊人。但是,Android Studio的布局工具会显示以下内容

generic image

为什么Android Studio中无法显示正确的图像?

这看起来像是普通图像。该图像在设备上显示正常,但其父设备溢出。我也不明白,但是我可以肯定地说,如果我能先说服Android Studio显示图片,就可以解决溢出问题。

解决方法

您在屏幕截图的左上角看到了那些蓝色框吗?点击那些。您将看到选项“设计”,“蓝图”和“设计+蓝图”。您选择了“蓝图”,但是想要“设计”。切换可以让您获得:

enter image description here

A,预览不会在这里溢出,因此我必须以其他方式解决我的问题。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...