I would like to enable ScrollView and disable it by a Button Click.
Disable means like if the ScrollView wasn't there.. and enable it returns the ScrollView.
I want that because I have a gallery with text images, and on a button click the screen orientation changes, so in Landscape the text becomes bigger. And I want the ScrollView so the image does not stretch itself and the text becomes unreadable.
scrollview.Enabled=false / setVisibility(false)
doesnt make anything.
xml:
<ScrollView
android:id="@+id/QuranGalleryScrollView"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<Gallery android:id="@+id/Gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal"></Gallery>
</ScrollView>
Thanks
Edit1: I can't use Visibility (gone) since that would also hide the Gallery, what I want is to hide the effect of the ScrollView. When there is ScrollView the images in Gallery become scrollabale and do not fit in the screen so u have to scroll to see the whole image, I don't want to disable/enable that on a button click.
I tried this:
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setOnTouchListener(null);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setHorizontalScrollBarEnabled(false);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setVerticalScrollBarEnabled(false);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setEnabled(false);
But still the images in the Gallery are scrollable and not fit the screen.. whats the solution to this?
Several points to begin with:
onTouchEvent
method to returnfalse
when some condition is matched.android:scaleType
property (XML) or thesetScaleType
method - for instanceScaleType.CENTER
will not stretch your image and will center it at it's original sizeYou could modify
ScrollView
as follows to disable scrollingYou would then use
in your XML file (just changed the
ScrollView
to your specialLockableScrollView
).Then call
to disable scrolling of the view.
I think that you have more than just the issue of disabling scrolling though to achieve your desired result (the gallery will remain scrollable with the above code for instance) - I'd recommend doing some more research on each of the three components (Gallery, ScrollView, ImageView) to see what properties each one has and how it behaves.
I had a layout over the NestedScrollView consuming the touch event and disable the scroll:
and to enable:
to start, i used the Code posted posted in the first Comment but i changed it like this:
then i called it in by this way
because i tried
but it said that setIsScrollable is undefined
i hope this will help you