konstantin_doncov
konstantin_doncov

Reputation: 2879

ImageView not showing some images

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?

Upvotes: 0

Views: 2303

Answers (1)

Elltz
Elltz

Reputation: 10869

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

Upvotes: 3

Related Questions