I have a webview inside a scrollview with javascript listening click event.
It is no problem to listen it in normal case but cannot be listen just after scroll. I need to have a first click to stop the scroll and click one or two times to trigger the click event. Or wait a while until the scrollbar fade out.
I have done a research and know it is normal behavior of scrollview. I have try to set a ontouchlistener on webview to requestDisallowInterceptTouchEvent(true) but just make it cannot able to scroll anymore. Is it there are any approach to cancel the scrolling and perform a click at the same time with no delay in a scrollview?
Finally, I have solved it by reading the document. I just put android:descendantFocusability="blocksDescendants"
in the main child view of scrollview and then solve my problem.
For Gopal Singh Sirvi asking, I think you need to put a webview in a scrollview in some cases. Let say the data of one section contains html code. I guess the content page of gmail is also like this. (After open show layout bounds, the content seems inside a webview but others not)
Hope this help!
I have multiple textviews inside a horizontalscrollview. Now I want to scroll all the textviews inside it so that all multiple textviews gets displayed. How can I achieve it ?
Thanks in advance.
Here is one git project. Its a scroller the scroll automatically and continously. It was made to show a credits screen by continously scrolling through a list of images.
This might help you or give you some idea.
https://github.com/blessenm/SlideshowDemo
I need to implement a UI like this:
In the above screen row needs to be scrolled horizontally and columns need to be scrolled vertically.
I have not used Gallery as It is being deprecated. Here are some scenarios which I have tried:
1. Combination of GridView and ListView.
2. Combination of ListView and Horizontal ListView(Custom Component).
Option 1 did not work for me but I could make it with option 2.
With option 2 perfomance is not good.
Solution: I am thinking of implementing 4-5 horizontal listviews inside scrollview with Gestures so that I can handle the vertical swipe thru code or by subclassing the ScrollView and overriding the onScrollChanged method.
But I am looking for some more optimized solution.
Any help is appreciated.
Thanks
Use webview and push the content into it through JS hooks.
I have gone with my solution if anyone can suggest a better solution then obviously I will go with it:
Solution:
Implemented 4-5 horizontal listviews inside scrollview with Gestures
and handled the vertical swipe thru code or by subclassing the
ScrollView and overriding the onScrollChanged method.
I have a problem where I have several TextView objects in my Activity. More than can fit on the screen view so I have placed them inside a ScrollView.
Now each TextView item is placed into a RelativeLayout before placing onto the ScrollView.
Each RelativeLayout object then has onClickListener and onFocusChangedListeners assigned.
Each Listener implements a method that pops up a dialog to enable the user to edit the value stored by the TextView.
The problem that is occuring is that when the screen is scrolled the onFocusChangedListener event is fired causing the dialog to appear for several items at a time.
Is it possible to detect if the Scrollview is scrolling and prevent the onFocusedChanged event firing?
I can post code if required but its quite large as the items added to the page are done so dynamically. This also means there is no xml for the layout.
I looked at using the ScrollView onTouchListener to add a flag ignoreFocusChange but it appears this would not work as the event was hit sveral times for one swipe/fling on the screen.
Please help
Regards,
Iain
After spending some time on this I found that the best solution for me was to remove the onFocusChangedListener and replace it with onTouchListener
Got a little problem with a functionality I'd like to implement.
I've got a LinearLayout, containing 2 TextViews. I'd want to set a onClickListener on it, so that it would behave just like an item in a ListView.
I've tried some possible implementation of this, and got it working using the xml attribute android:onClick of the LinearLayout.
As I want the application to visually react to a click on the LinearLayout (as in a ListView), I put this in the listener callback method :
l.setBackgroundColor(android.R.drawable.list_selector_background);
l is a LinearLayout object, initialised with findViewById();
I get an application not responding whenever I try to click on the layout. I tried to replace the code in the callback method by a Toast message show up, and it works, so I guess the problem is in the setBackgroundColor.
Is anyone familiar with this?
PS: sorry, I can't post more code right now, I'm at work.
You have to set LinearLayout attribute android:clickable="true" in the xml layout file or setClickable(true) in the java activity code.
i noticed that all the advices above don't helpt as long as any of the child elements inside the LinearLayout has the attribute android:textIsSelectable="true".
I found that that setClickable(true) would still cause clicks to go to children of the linearlayout. I found that to have the LinearLayout capture the touch instead of it's children I had to override the dispatchTouchEvent method so I created a subclass of LinearLayout for just this purpose. Seems like an ugly solution though.
you should set the LinearLayout's focusable to true and set all the children view's focusable to false, don't use the android:clickable="true", but you can't see the effect of the click of the linelayout. BTW, the best way is to implement the onTouchEvent api.
android:clickable="true" works perfectly under one condition.
Youhave to put the childs inside the LilnearLayout to android:clickable="false".
Had the same problem, I've been trying for an hour all the answers in SO but none worked.
Then I realized I just had to promote my LinearLayout to the bottom of the layout, since other views blocked it, and then it worked, without adding ANY special attributes to the layout.
Putting it here in case it might help someone someday.