J. VR
J. VR

Reputation: 23

ImageView not displaying (Android)

I have this code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.example.ioann_000.cainstructionquiz.PlayActivity"
    android:clickable="false"
    android:animationCache="false"
    android:clipChildren="false"
    android:contextClickable="false"
    android:filterTouchesWhenObscured="false"
    android:layout_alignParentBottom="false"
    android:layout_alignParentRight="false"
    android:saveEnabled="false">


    <TextView
        android:text="@string/CainstructionQuiz"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="12dp"
        android:id="@+id/CainTxtView"
        android:textSize="30sp"
        android:textColor="@color/colorPrimary"
        android:textStyle="normal|italic" />

    <Button
        android:id="@+id/exit_btn"

        android:textColor="#121111"
        android:textSize="30sp"

        android:layout_width="120dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="7"
        android:shadowDy="-2"
        android:shadowRadius="25"
        android:layout_height="39dp"
        android:layout_marginBottom="25dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="ΕΞΟΔΟΣ"
        android:elevation="0dp" />

    <Button
        android:id="@+id/Start_btn"

        android:text="@string/PlayTxt"
        android:textColor="#121111"
        android:textSize="30sp"

        android:layout_width="120dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="7"
        android:shadowDy="-2"
        android:shadowRadius="25"
        android:layout_height="39dp"
        android:layout_marginBottom="24dp"
        android:layout_above="@+id/exit_btn"
        android:layout_alignStart="@+id/exit_btn" />

    <ImageView

        android:layout_width="200dp"
        app:srcCompat="@drawable/maths_0"
        android:id="@+id/imageView2"
        android:layout_height="150dp"
        android:layout_marginBottom="74dp"
        android:layout_above="@+id/Start_btn"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

but the imageview isnt showing... i tried to remake the imageview but nothing happens, when this is on design mode showing but when i am running the app, not. Any help please? Thank You!

Screenshot on Design Mode

Screenshot on Run Mode

Upvotes: 2

Views: 78

Answers (1)

John Joe
John Joe

Reputation: 12803

Add android:src="@drawable/yourImage" or android:background="@color/red" then you will see your ImageView.

Edit

Replace app:srcCompat with android:src.

Upvotes: 1

Related Questions