Image not showing in android studio emulator - android

i don't know what is the problem with my android studio i am trying to add an image from image view ..it is showing in design tab but not in emulator ...i am a newbie ..please help me fix it ..thanksAndroid Studio
i tried fixing it by changing the attributes but didnt work ..

You are setting a sample_image to an imageView. To set an image, give it a real source.
android:src="#drawable/any_image"
give source of an image drawable

Download any jpg or png image from google and paste that image in drawable folder than add this line in to you imageview widget -> android:src="#drawable/TestImage"
like this->
<ImageView
android:id="#+id/imageview"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="#drawable/TestImage">

Related

Wrong 9 patch init size while displays

Created nine patch image via Android Studio from png file. Set patch image as background on ImageView, but ImageView shows with greater size as expected. Studio shows that image has size 117*95, but on display imageView shows with size near 334*266.
Please, help how to fix it. Png and screens attached.
<ImageView android:background="#drawable/new_sent_bubble_edit1" android:layout_width="wrap_content" android:layout_height="wrap_content" />
nine patch view in studio
Found solution. Just need to put 9 patch file to some density drawable folder. When put picture to xxhdpi-drawable folder and image has been drawn as expected.

Showing a gif with transparent background in an ImageView

I have a coloured gif image that I would like to use in my application, I imported the image into my application by dropping and dragging the gif into res/drawable.
However the transparent background turns white when it is shown in an imageview, here is my code
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitXY"
android:src="#drawable/logo"/>
How can I make android show the transparent background and not a white one?
Thanks
I think its better to open a gif in a webview. you can put the gif file in a html file and open it in webview. also you can set your app background in html file to make your work easier.

Why Android Studio button displaying image as expected but on real device showing some other image?

I am using Android Studio version 2.2. I am facing strange thing first time. In one of my layouts I am using image ‘abc.png’ and Android Studio preview showing the right preview with right image, but on real device the image is different. The real device getting image wrong constantly. I don’ know what am I doing wrong? Below is the button code.
<Button
android:id="#+id/btn_pay"
android:textColor="#525252"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="30dp"
android:background="#drawable/btn_normal"
android:text="Pay" />
Android studio is showing this preview as expected because 'Button image' (text 'Pay' is placed) I am using is what it should be.
but on real device it is showing different image as shown below
The button is getting wrong image on real device. One more thing I have checked some this button with other colored images as background it is properly reflected on android studio preview but on real device it always shows the same image no matter what image I use on background. Any help?
After struggling a lot, I have found the problem. The problem was not with Button png or xml drawable. The problem was in java coding. The image was placed programmatically. I have posted the answer in case it may help full for others.

How can zoom image with multiple Touch in android?

I am going to create image gallery. How can i zoom image using multiple touch. i got pinch-0.8 library but how can i use it. if you have any other idea then help me.
Zoom effect with ImageView in android.
There is a library available at Image Zoom
Download two files
ImageViewTouch.java
ImageViewTouchBase.java
To use image view inside your layout file, write following code
<com.package_name.ImageViewTouch
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:src="#drawable/image" />
NoTe
Make sure, you have put those files inside any package, like com.customview or something like that. So that you can refer that in layout file.
Link
You can download sample from sephiroth/ImageViewZoom

Android - ImageView does not display image. Nor does setImageResource()

I use an ImageView control as shown:
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imgHangMan"
android:src="#drawable/hang0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
The above code displays the image in the Graphical Layout preview of the xml file. But on launching the app, I see no image. Also, changing the image using
imgHangMan = (ImageView)findViewById(R.id.imgHangMan);
imgHangMan.setImageResource(R.drawable.hang1);
This piece of code also does not work either. The image files are in .gif format and are in the drawable folder.
Any pointers ?
Natively ImageView doesnot support animated image. You have two options to show animated gif file
1) Use VideoView 2) Use ImageView. But Split the gif file into several parts and then apply animation to it.
Try this link-playing-gif-animation you will get the desired result.
Try this
image.setImageDrawable(getResources().getDrawable(R.drawable.hang1));
User this :
http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
Go by this.

Categories

Resources