Android Load Image from Drawable - android

i need to create a object Image from import javax.microedition.lcdui.Image; using a file .png placed in drawable folder. How can i do that?
Thanks

Since this Android and not JavaME, you cannot create a javax.microedition.lcdui.Image. You would create a Bitmap instead. Here's a decent tutorial on working with images in Android.

Related

how do you use svg in drawable folder?

i am creating a bottom navigation bar for a android app following this guide
however, when using svg in android:icon and building it, it shows a error
Error: The file name must end with .xml or .png
i found out that i needed to move the svg to the assets folder. but if i move it, i can't use the svg... any help is much appreciated, thank you
The answer above gives a link to convert pictures from SVG to XML, but this tool is not for free(only for one SVG file)
So why not to use ANDROID build-in tool?
The best way is to go to res-> drawable-> Vector Asset -> Local file (SVG, PSD) ->select your SVG file from the place you save it.
and you are done :)
Android uses vector drawables which are xml files rather than SVG's.
You will have to convert the SVG to a vector drawable. Many ways of doing it but a handy web tool is available here.
It won't do complex SVG's but copes with the majority.

Using android vector drawable inside HTML

I need to display a vector drawable which is present in drawable folder in a WebView. This is for a native android app.
If I use the code:
<img src="file:///android_res/drawable/example.png"/>
It works for png/jpeg images, but is there any way to display vector drawable (with .xml extension) inside a WebView?
Any help would be appreciated. Thanks in advance

How to replace default android loading image with .gif image in android application

I have worklight android application and using default loading provided by jquery, want to replace default loading with another .gif image. can someone help me from where default image can be replace.
Thanks in advance
I think, You have to place .gif image in a drawable folder and get that .gif images and place drawble folder,all the gif and image, application take that folder by default. If you don't have drawable folder create just under the res folder.
There is new library Glibe for displaying gif file in android, It is easy to use, Like this,
String gifUrl = "http://i.kinja-img.com/gawker-media/image/upload/s--B7tUiM5l--/gf2r69yorbdesguga10i.gif";
ImageView imageViewGif= (ImageView) findViewById(R.id.imageViewGif);
Glide
.with( context )
.load( gifUrl )
.into( imageViewGif );
Don't forget to import the Glibe dependencies on gradle file.
By loading image, if you are referring to splash screen, in a MobileFirst Hybrid application custom splash screen needs to be placed in "res/drawable" folder. However ,this cannot be a .gif file. It has to be a png.
For more details refer this link.

Android setThumb(drawable) variable type?

All,
I'm trying to dynamically change the image displayed on the thumb of the seekbar in java, and came across the setThumb method. I have a .png file under res/drawable, but can't find the right way to refer to that .png file using setThumb(). Do any of you know how to do it?
Best and Thanks in Advance!
You need to create a drawable from your resource.
Drawable mypicture= getResources().getDrawable(R.drawable.mypicture);

Write image in drawable using android 2.1

I have a bitmap object. I want to overwrite a .png image under drawable folder with the bitmap object content. I need a sample code to do this.
Thanks in advance
You can't overwrite resources in your application.
You can instead write to the internal memory or the sdcard.

Categories

Resources