Вопрос

I have an image in my application. But size of the image becomes larger for smaller screens. So I tried by adding scroll view for the image.

Code:

<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbarFadeDuration="10"
    android:scrollbarAlwaysDrawHorizontalTrack="true"
    android:scrollbarAlwaysDrawVerticalTrack="true" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="400dp"
    android:layout_height="500dp"
    android:contentDescription="@string/image"
    android:layout_marginLeft="160dp"
    android:scrollbarThumbHorizontal="@id/imageView1"
    android:scrollbarThumbVertical="@id/imageView1"
    android:src="@drawable/abc" />

</ScrollView>

But this allows me to scroll in vertical direction only. Help me what do so that I can scroll the image in horizontal direction also.

Это было полезно?

Решение

A simple solution might be to scale the image to fit the the screen using scaleType. To include horizontal/vertical scrolling, take a look at this post.

Другие советы

You can use TouchImageView. This project adds touch functionality to android imageView. Scroll, pinchzoom etc.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top