2014-12-22 73 views
0

我想在Visual Studio 2012的Xamarin插件中使用ImageView,但是當我使用像src這樣的透明背景的png時,我只能看到黑色屏幕。 這很奇怪,但前段時間我可以做到,但現在我不能。 Visual Studio中的照片查看器顯示我的圖像只是黑色。 當我在設備上運行我的應用時,我也會看到黑屏。 這裏是XML:ImageView不顯示一些圖像

<?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> 

以前,我沒有這個問題,我想......

如果我使用的ImageButton相同的圖像,當我使用的圖像沒有透明背景的一切OK! 重命名文件夾Drawable沒有幫助。

我該如何解決這個問題?

+0

你能提供有問題的圖像的鏈接?我可以嘗試在我身邊... –

+0

@ÜberLem好的,謝謝! https://drive.google.com/file/d/0B4jsXYhk52gaRGpHRnZrNl85SWc/view?usp=sharing –

回答

3

這就是我認爲的,你的圖像有一個透明的背景,已經是 ,並且你還將小部件背景設置爲透明 ,現在默認情況下,你的活動或佈局主題,通過猜測具有黑色背景。 .so檢查了這一點..圖像有一個透明的背景和圖像是一個黑色的圖像, 和你的部件有一個透明的背景,往往會顯示你的主題的背景是黑色的 ,所以你的圖像淡入,背景圖像顯示的圖像,但由於圖像本身的opage部分是黑色的你得到一個黑色的屏幕這是一個瘋狂的猜測,所以這樣做..設置linearLayout背景可以說紅色或白色,並且一切都會好起來

<?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> 

編輯:我誤解你的問題,我的錯誤是我地合計也爲小部件指定透明度所以,我承認我的錯誤,但我的邏輯仍然停留,這一次是一個事實,你的佈局主題是黑色的和每一個部件遵循,因爲你不指定它,你的形象是黑色的,它仍然顯示黑色..

注意這是野生guess..ayt所以儘量吧..讓我知道

+0

謝謝!那麼愚蠢的問題... –