Click here to Skip to main content
15,920,031 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I take image to .xml file where user profile is going to display when user did upload image from device or gallery and by default place of image view it will be default image. using Android Studio. So please help me out of this problem.

What I have tried:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.vixcy.thecontacts.dashboard"
tools:showIn="@layout/app_bar_nav_drawer">


<TextView
android:id="@+id/textView1"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="300dp"
android:text="TextView"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"/>

<LinearLayout
android:layout_width="200sp"
android:layout_height="200sp"
android:layout_marginLeft="85sp"
android:layout_marginTop="50sp"
android:orientation="vertical">


<ImageView
android:id="@+id/imgView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:elevation="10dp"
android:padding="1dp"
android:scaleType="centerCrop"
android:visibility="visible"
app:srcCompat="@mipmap/dummy">




<button
android:id="@+id/buttonLoadPicture"
="" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:onclick="onClick" android:text="Load Picture">




<TextView
android:id="@+id/textView2"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="350dp"
android:text="TextView"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"/>
Posted
Updated 25-Jun-17 4:56am

1 solution

Use
android:src="@drawable/dummy"
instead of
app:srcCompat="@mipmap/dummy"
Also, you should put the default image to drawable folder, not mipmap folder. Mipmap folder is only for icon.
You can see the difference from this post
android - mipmap vs drawable folders - Stack Overflow[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900