2013-08-28 28 views
0

我想顯示的是image這是比屏幕更長的。我在scroll view內使用ImageView。我得到一個白屏,這是滾動imageheight,但圖像本身沒有提出Android ImageView在ScrollView中顯示白色屏幕

下面是我使用佈局的xml: -

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    tools:context=".MainActivity" > 


    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/test_image_content_description" 
     android:adjustViewBounds="true" 
     android:visibility="visible" 
     android:src="@drawable/test_image" /> 

</ScrollView> 

test_image.png是一個文件,該文件是在應用的所有 「drawable」 文件夾中找到。

任何幫助將不勝感激!

+0

它是否在您的圖形佈局顯示? –

+0

嗨,是的。它在圖形佈局中可見,因爲我希望它在實際運行時看起來像。 – dcoder

回答

0

在你ScrollView

變化android:layout_height="wrap_content"android:layout_height="math_parent"

+0

更改了它。仍然相同.. – dcoder

+0

@dcoder它可以是因爲ImageView縮放圖像。您可以嘗試將ImageView的scaleType更改爲「fitXY」,或將ImageView替換爲View,並將圖像設置爲背景。 – Yoric

0

您可以將scaletype添加到您的ImageView,就像使用android:scaleType="center"居中圖像,沒有規模,那麼你應該從imageview的刪除代碼android:adjustViewBounds="true"。詳情請參閱ImageView.ScaleType。謝謝

0

好的,我發現了這個問題。看起來問題在於圖像的高度爲6000像素,Android願意顯示的最大尺寸(即使在ScrollView中)也是4096(即使我添加了縮放比例)。

調整圖像大小後,顯示沒有問題。

謝謝大家的回覆!

+0

你在哪裏找到限制數字高度** 4096 **。我發現它顯示在一些大尺寸屏幕上,而無法以小尺寸顯示。 – zionpi