kotlinandroid-studio

Why i can't see the image logo in the preview blueprint in android studio?


my image file name logo.png is in the project folder es/drawable.

[logo.ng file image is in the folder drawable

the xml code:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:background="@android:color/white"
    android:padding="16dp">

    <ImageView
        android:id="@+id/logo.png"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/logo"
        android:contentDescription="@string/app_name"/>

    <TextView
        android:id="@+id/welcome_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/welcome_to_"
        android:textSize="24sp"
        android:textColor="@android:color/black"
        android:layout_marginTop="16dp"
        tools:ignore="HardcodedText" />

    <!-- Optionally, add a button or other elements here -->

</LinearLayout>

i tried only logo and then logo.png in this line

android:id="@+id/logo.png"

but the blueprint preview is not showing the logo.png

not showing the logo.png in the blueprint preview.


Solution

  • try this in ImageView

    android:src="@drawable/logo.png"