1

I'm working on application that want show a long-width image as below to the user. user can drag image to the right or left, to see entire image or use Gyro-Sensor instead. this is what i want

so, i used HorizontalScrollView in android with layout code below to achive want i want

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="net.appersian.android.wod.MainActivity"
android:background="#000"
 >

<HorizontalScrollView
    android:id="@+id/scrollContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:fillViewport="true"
    android:measureAllChildren="false"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    android:scrollbars="none" >

    <ImageView
        android:id="@+id/scrollView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/panorama_ph" />
</HorizontalScrollView>

this code works great on High-end device like Nexus 5 but the problem is started when i test the app on Nexus S(512MB ram) on android 4.2! image is not shown and in logcat, i get continusly this error:

09-09 13:58:27.539: W/OpenGLRenderer(7925): Bitmap too large to be uploaded into a texture (6759x1136, max=2048x2048)

i don't know either how to implement this effect without Horizontalscrollview or how to fix the problem! can anyone help me to fix this problem?

Ali Abdolahi
  • 324
  • 3
  • 10
  • to fixing your problem : http://stackoverflow.com/questions/10271020/bitmap-too-large-to-be-uploaded-into-a-texture – Arash GM Sep 09 '14 at 09:35
  • 1
    thank you, but is there any other way to achieve this effect without horizontalscrollview? – Ali Abdolahi Sep 09 '14 at 09:48
  • i'm not sure about that but might be achievable with a one page ViewPager with setting page margins, but it's just a guess. – Arash GM Sep 09 '14 at 09:52

1 Answers1

0

you can try use photoView

        <uk.co.senab.photoview.PhotoView
            android:id="@+id/photo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone" />

MainActivity.class

import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;

 public class MainActivity extends Fragment{
        PhotoViewAttacher mPhotoAttacher;
        PhotoView mPhoto;

        mPhoto = (PhotoView) rootView.findViewById(R.id.photo);


                public void imageView(String imageUri, View view, Bitmap loadedImage)
                    {

                    mPhoto.setImageBitmap(loadedImage);
                    mPhoto.setVisibility(View.VISIBLE);
                    mPhotoAttacher = new PhotoViewAttacher(mPhoto);
                }
        }
Htut
  • 267
  • 3
  • 18