MvvmCross binding image file to Android ImageView - android

I am trying to bind an image file to an Android ImageView that is within an MvxListView. The images are just not appearing when the View is shown.
I have included the MvvmCross.HotTuna.Plugin.File package.
ListVideo.axml (snippet)
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/holo_blue_bright"
local:MvxBind="ImageUrl Thumbnail" />
The typical value for Thumbnail is
VideoData/2015-07-24-09-26-16/2fea9249-9370-4542-927a-c856e678f7b1.jpg
The value of Context.FilesDir.Path is /data/data/com.app.AppName/files
The image file /data/data/com.app.AppName/files/VideoData/2015-07-24-09-26-16/2fea9249-9370-4542-927a-c856e678f7b1.jpg does exist
I understand that to bind an image some custom folder determined within your app, I need to provide a path relative to Context.FilesDir.Path in order for the plugin to load it. I believe that the string in Thumbnail is correct.
But nothing is displayed in the ImageView. I have been banging my head against this one all morning. Any suggestions?
Edit :
I have managed to solve the problem !!
I needed the MvvmCross.HotTuna.Plugin.DownloadCache as well as the MvvmCross.HotTuna.Plugin.File package.

I have managed to solve the problem !!
I needed the MvvmCross.HotTuna.Plugin.DownloadCache as well as the MvvmCross.HotTuna.Plugin.File package.

Related

Android studio can not detect the source file in res/drawable

This is my code. I don't know how to post this image.
I tried to add source file for my ImageView. But it doesn't work. I tried to copy the path folder and it is still not work.
Solution - first problem
The resource name must start with a letter (not number).
Solution - second problem
Use just:
#drawable/039_cloud
instead
#drawable/039_cloud/039_cloud
so:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/039_cloud" />
Android Studio
Android Studio is grouping same images, but for different DPIs.
When you choose Android view, you will have:
But when you will choose Project you will see "real" project structure:
Copy the image resource and paste it directly inside the drawable folder. Rename the image such that no number is included (e.g. image_thirty_nine.png). Then try this
<ImageView
android:id="#+id/image_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_thirty_nine" />
If you are till getting the same error after trying the above step, then try adding the image resource programmably
//ensure you assignn an id to your image
ImageView imageView = findViewById(R.id.image_id);
imageView.setImageResource(R.drawable.image_thirty_nine);
then run your code to see if it works

ImageView doesn't appear

I have dragged an ImageView to layout and I selected the picture. But when I execute the application, It doesn't appear. What can I do to solve this ?
ImageView XML code;
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:srcCompat="#mipmap/idlepoor_moneys"
android:id="#+id/imageView4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
Add this property in Your image View
android:src="#mipmap/idlepoor_moneys"
Remove the following line from your code
app:srcCompat="#mipmap/idlepoor_moneys"
As allready said change
app:srcCompat="#mipmap/idlepoor_moneys"
to
android:src="#mipmap/idlepoor_moneys"
Also I recommend to put your images in the #drawable folder. The mipmap is where app icons are stored when making an app.
app:src="#drawable/idlepoor_moneys"
You can easily find the drawable from your project map. If you can't find it you can always right click the folder to get the path to it.

Image loading in android studio

I am not able to load the image. I tried the following
put the image in the drawable folder
then use the Image View tag
then able to load the picture for the app's icon, but not able to if I try to use picture inside my application.
what should I do to use a picture inside the created application
If you want to use an image from drawables you shold reference it from your layout via ImageView control:
<ImageView
android:id="#+id/this-is-your-image-view-id"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.00"
android:src="#drawable/this-is-your-drawable-name" />
I faced the same problem,fixed by using .png image,not other format .

Android Imageview

I have kept some .png file in res->drawable-hdpi and now, I want to show it in imageview in android. But when I refer to that image from image view, android says:
Couldn't resolve resource #drawable/my_pic.
I am using the following code :
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/my_pic" />
I am using every file name in small letter
The size of my_pic is 36kb
So how can I load the picture? Is this problem for size or something else. How to fix this problem. Any help ?
If you dont save your changes, you get a
"Couldn't resolve resource #drawable/my_pic."
Control+S ... to save Changes, its all or..
When the R.java have a problem, only needs:
(Project -> Clean from the menus)

Is it possible to use the default android loading animations on an ImageView?

I know android uses their own loading animations through that are included with the android.jar...however I have not been able to successfully get them to work with an ImageView correctly. For instance, the following code gives me an error in my xml file that says the image is not public...is there anyway to get this to work correctly or is it even possible?
<ImageView android:layout_height="wrap_content" android:id="#+id/loadingImg"
android:layout_width="wrap_content" android:paddingTop="6px"
android:paddingLeft="6px" android:src="#android:drawable/spinner_white_16">
</ImageView>
I know its possible to slice a loading gif up and use animation-list however it would be convenient to just use android's images.

Categories

Resources