Mickey Evers
Mickey Evers

Reputation: 151

Android image not showing in imageview

I am having problems with my xml file. I want to show a picture but the picture is not showing. Strange thing is I am using the same picture in an other part of my app and there everithing is working fine. The foto I am using is also showing in android studio but not on my phone. You can find my xml below.

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgroundcollor">  

 <ImageView
    android:id="@+id/imgPersoon"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="65dp"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    app:srcCompat="@drawable/persoon" />

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imgPersoon"
    android:fillViewport="false"
    android:orientation="vertical"
    android:padding="10dp">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

        <TextView
            android:id="@+id/txtName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_marginTop="14dp"
            android:text="Naam:"
            android:textAlignment="center"
            android:textColor="@color/colorPrimary" />

    <EditText
            android:id="@+id/txtFirstName"
            android:layout_width="match_parent"
            android:layout_height="25dp"
            android:layout_below="@+id/txtName"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/rounded_button_grey"
            android:ems="10"
            android:inputType="textPersonName"
            android:text="Name"
            android:textSize="14sp" />

    <EditText
        android:id="@+id/txtLastName"
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:layout_below="@+id/txtFirstName"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/rounded_button_grey"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Name"
        android:textSize="14sp" />

    <TextView
        android:id="@+id/txtDate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtLastName"
        android:layout_marginTop="14dp"
        android:text="Naam:"
        android:textAlignment="center"
        android:textColor="@color/colorPrimary" />

</RelativeLayout>

</ScrollView>
</RelativeLayout>

Upvotes: 7

Views: 38286

Answers (5)

Manas
Manas

Reputation: 958

The bigger size of an image could be an issue as well. Resize the image to a smaller size (using paint in windows) and use it, this might work.

Upvotes: 1

Sunil Shakya
Sunil Shakya

Reputation: 9437

application extend AppCompatImageView. I Use

android:foreground

this work for me.

Upvotes: 1

Mohammad Hossein jfp
Mohammad Hossein jfp

Reputation: 528

You cloud use Following code for set Image

android:src

or

android:background

Hope it help

Upvotes: 4

Anuj Kumar
Anuj Kumar

Reputation: 1162

I think You should edit srcCompat to src. src is meant for source and sourceCompat Is for Backwards Compatiblity Of Vector Drawable Files For Android Devices Running On and below ICS -- IceCream Sandwich.

Upvotes: 1

Josh Laird
Josh Laird

Reputation: 7214

Use android:src instead of app:srcCompat

Upvotes: 47

Related Questions