ImageView not showing some images - android

I'm trying to use the ImageView in Xamarin plug-in for Visual Studio 2012, but when I use png with transparent background like a src I get just black screen.
That's strange but some time ago I could do it, but now I can't. Photo viewer in Visual Studio shows my image just black.
When I run my app on the device I get black screen too.
Here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Previously, I did not have this problem, I think...
If I use the same image in ImageButton and when I use image without transparent background all ok!
Renaming folders Drawable does not help.
How can I resolve this issue?

this is what i think, your image has a transparent background, already, and you also set the widgets background to transparent, now by default your activity or layout theme, by a wild guess has a background of black..so check this out.. Image has a transparent background and the image is a black image, and your widget has a transparent background which tends to show you the theme's background which is black, so your image fades in, to the background image showing the image but since the image itself opage portion is black you get a black Screen this is a wild guess, so do this.. set your linearLayout background to lets say red or white, and everything is gonna be alright
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:background="#fc9" // red or you could do it #fff white
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Edit: i misread your question, my error was i tot you also specify transparency for the widget so, i admit my error, but my logic still stays, this time being the fact that, your layout theme is black and every widget follows that because you do not specify it, and your image is black, it still shows black ..
Note this is wild guess..ayt so try it.. and let me know

Related

Splash Screen Background Image color inconsistent

I have a Splash Screen with a background Image on top of it. I have a Video View which plays the video. The background of the video and that of the rest of the screen must match, hence I extracted the background color from the video and added a background image of the same color in the XML file.
The problem is, the color of the image does not match with the video on all versions of Android.
On Sony Xperia SP with v4.3:
On Micromax A1 with v6.0.1:
How do I get consistent result across all (or most) versions of Android?
XML of Splash Screen:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/logoback"
>
<VideoView android:id="#+id/myvideo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Instead of using drawable for setting the background, extract the colour code and set the colour code to background. It might resolve the issue.

How do I get a background image to scale in android studio?

So I am trying to import a custom image as the background of an android app however it does not fill in all of the edges. The option I have seen is to set a second layout to be a frame layout and then place an image view within it with additional coding along the lines of android:scaleType="centerCrop". This will not fill the entire screen up for me however, heres a screenshot of what ends up happening -
Heres the xml code being used:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/backgroundImage"
android:background="#drawable/backgroundImgr"
android:scaleType="centerCrop"
/>
</FrameLayout>
Another issue is that different users use different resolutions so the background image has to be able to accommodate them all without being cut off. I'm not sure how to do this.
Set ScaleType fitXY and add android:adjustViewBounds ="true"
Please use android:src="#drawable/ instead background .I hope it will helps you.

No resource found that matches the given name keeps showing

when am trying to put a background to the layout the app just stops and exit ("unfortunatly, xxxx has stopped working") although the splash and main layouts works fine but as soon as i enter a new layout ex: contact us page ) with no background the app works fine :S :S
here's the code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/ibg" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/au" />
</LinearLayout>
Try setting another background and check if the problem still exists. I thing there is some problem with your files in drawable folder. Try not setting a .gif image as background and set a jpg or png image.

How to make background larger then screen and rotate it?

Want to make space background to my activity and begin to rotate it slowly, but i stuck with that:
screenshot (http://postimg.org/)
The effect I need need I can get if add in XML file
android:scaleY="2"
android:scaleX="2"
but it will not work, android scale pic down when app start.
Guys, really need your help, I in android for 4 day and have bad english
----ADDED---
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/backgroundd"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
I have not tried this, and I am not sure it is the best solution, but could you set a negative android:layout_marginon the image?
android:layout_margin="-100dp"
See here for more: How to get a view larger than its parent?
Also, posting your full XML could help us know more about how you are setting up the layout.

Android background doesnt show correctly

Ok I have created a background image in Inkscape. Exported that image and it looks correct, when I open it from Eclipse. However, when I build the project and apply that background to the Layout, it shows the complete opposite in the designer and on the device.
Here is what the image is supposed to look like. Correct background
Here is what the image looks like in the Eclipse Designer.Incorrect background.
Here is my Xml on a brand new Xml file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/list_view_bg"
android:orientation="vertical" >
</LinearLayout>
I am utterly confused on this one. Any help is greatly appreciated.
You are most likely using a theme where the background in dark. As your background gradient is transparent the black background is showing through.
Switch to a light theme.

Categories

Resources