Full size image in ImageView

走远了吗. 提交于 2019-12-06 04:59:49

问题


I'm trying to draw an image in an ImageView, but i want it to be unscaled, with scrollbars as necessary. How can I accomplish this? Right now I just have a drawable set as the android:src of the ImageView in the XML. This autoscales the image to fit the screen width.

I read that this might be because of the compatibility mode (developing for 1.5, testing on 2.1), but then I added

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />

to my manifest, and nothing changed.

Any clues?

--

Edit: I used android:scaleType="center" on the ImageView, and this displays the full image (can't believe I didn't see this before), but I still only get a vertical scrollbar. Using android:scrollbars="horizontal" on the ScrollView that's wrapped around the ImageView (obviously) hides the vertical scrollbar, but doesn't show a horizontal scrollbar...


回答1:


check this example it helps




回答2:


This worked for me (using an HorizontalScrollView inside a ScrollView):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"    
    android:layout_height="fill_parent">


    <ScrollView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
    >
        <HorizontalScrollView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/imagen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="center"
            />        
        </HorizontalScrollView>
    </ScrollView>
</LinearLayout>



回答3:


I believe you have to size the ImageView to the size of the Bitmap and place the ImageView into a ScrollView. But you may run into memory issues trying to display a large image.



来源:https://stackoverflow.com/questions/2537396/full-size-image-in-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!