簡體   English   中英

ScrollView中的Android ImageView顯示白屏

[英]Android ImageView in ScrollView shows white screen

我想顯示的image比屏幕

我在scroll view使用ImageView 我得到一個白色的屏幕 ,該屏幕 可滾動imageheight ,但是圖像本身未顯示

這是我正在使用的布局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 ”文件夾中找到。

任何幫助將不勝感激!

在您的ScrollView

android:layout_height="wrap_content"更改為android:layout_height="math_parent"

您可以向您的imageview添加一個scaletype,例如使用android:scaleType="center"將沒有縮放比例的圖像居中,然后您應從imageview中刪除代碼android:adjustViewBounds="true" 有關詳細信息,請參見ImageView.ScaleType 謝謝

好的,我發現了問題。 似乎問題在於圖像的高度為6000像素,Android願意顯示的最大尺寸(即使在ScrollView內部)也為4096(即使我添加了縮放比例)。

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

謝謝大家的答復!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM