I need to make a credits screen in my application. It would be vertically scrolling lines. It is html page with images so I can only use webview. Scrolling is to be performed automatically and no user interaction is allowed. Just like movie/serials credits that goes from bottom to top. I have html page added in assets folder.
How to implement this animation?
Since you are using a webview, you can actually use jQuery to accomplish this.
$('a[href=#bottom]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
Slow down scroll to top event by jQuery animate
Or you could use a handler
private Runnable mScrollDown = new Runnable()
{
public void run()
{
WebView webview = (WebView)findViewById(R.id.web_url);
webview.scrollBy(0, scrollSpeed);
mHandler.postDelayed(this, 200);
}
};
Related
I have lots of contents on one page so i am using scrollview. I have one scan button at the bottom of the page, which i need to click many times to scan lots of barcodes. when i click on scan button, i am opening "BarcodeScanner" application that will sacn the barcode and returns the result to my application. so when i come back to my application, again i need to scroll the entire page to click the scan button which is at the bottom side. So is there any way to initialize the scroll at the bottom of the page? Please help
Thanks in advance
How do you think that you can initialise the scroll view.!! If you have lots of contents in a page you have to use scroll view for seeing all the contents. ! Try this, put your scroll view xml code in to botom of the xml code. and check.!!
Say your ScrollView id is scrollId, the code will lokk like this
scrollView = (ScrollView) findViewById (R.id.scrollId);
scrollView.post(new Runnable() {
#Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
Try this
s.post(new Runnable() {
public void run() {
s.scrollTo(0, mScrollView.getBottom());
// or this
//s.fullScroll(s.FOCUS_DOWN);
}
});
I have a WebView which displays an HTML file and I would like to add an option to be able to scroll down automatically when a button is clicked with a given speed. How should I approach on doing this?
You can calculate the speed of button clicks by taking difference in unix timestamp between clicks and then you can impliment something like
private Runnable mScrollDown = new Runnable()
{
public void run()
{
WebView webview = (WebView)findViewById(R.id.web_url);
webview.scrollBy(0, scrollSpeed);
mHandler.postDelayed(this, 200);
}
};
I got the answer from link given below. Check it for details.
Auto-scrolling a WebView with handlers
You just need an HTML button which performs a JavaScript call.
Something like:
$('a[href=#bottom]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
Inspired by: Slow down scroll to top event by jQuery animate
I want my webview to show a webpage but not to have any interaction with the page at all.
Just show it. I an showing an iframe but when you click on the image in it it goes to a link. That link is to big for the frame. I need to disable being able to click it.
i have tried
WebView
android:id="#+id/wv_AmberAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:longClickable ="false"
and
wv_Amber_Alert.setFocusableInTouchMode(false);
wv_Amber_Alert.setFocusable(false);
wv_Amber_Alert.setOnTouchListener(null);
wv_Amber_Alert.setOnClickListener(null);
You can try attaching a WebViewClient to the WebView and override the onLoadResource() method to stop loading of the url:
WebViewClient client = new WebViewClient() {
#Override
public void onLoadResource(WebView view, String url) {
view.stopLoading();
}
};
wv_Amber_Alert.setWebViewClient(client);
I like to add an "overlay" FrameLayout over the WebView.
Make it the same size and position of your webview and make sure android:clickable="true"
When the webview is loading, I set my overlay to be visible. Vice versa for when loading completes.
It's also nice to add a semi-transparent background to the overlay - this explains to the user that the webview is loading and hasn't just frozen up (since interactions now dont work).
here's what I'm trying to achieve: I assemble a local html page with some tags and internet resources in it, and then load the html page webpage with WebView, and there's a "View More" button at the end of the page, when somebody clicks the button, I'll re-assemble the html page(with old data and new data, like refreshing twitter to load more twits) and have the WebView load it again. But as the user has scrolled to certain location when he clicks the button so I'd like to let the WebView to scroll to the very point where the user was before he clicks the button.
And here's what do by now, I create a WebViewClient and implements:
public void onPageFinished(WebView view, String url) {
view.scrollTo(last_X, last_Y);
}
It does not work as I expect it to, I have 2 concerns, guys please help me out:
1. this callback function does not work all the time. for most of the time, it works, but sometimes, for unknown reasons, it just does not work.
2. even if it works, it's not exactly what I want. as I mentioned, the html page contains some internet resources like
<a href='whateversite/whateverimage'><img src='whateversite/whateverimage'></img></a>
So the scrollTo function only got called when all images are loaded, it takes too much time and it's unnecessary, is there any way to start scrolling when the page is loaded but before all other resources got loaded? Per say, as long as webview.getContentHeight() > 0, it's OK to scroll.
Apologize for my poor english that I'll have to use load of words to try to make myself clear.
Guys, please halp~
Do something like this :
view.post(new Runnable() {
public void run() {
view.scrollTo(last_X, last_Y);
}
});
in my app i have place a text view in the middle of the layout and when i scroll screen to left i want to show the google maps. So far i am showing the google aps by ontouch method.
how to perform this...
You can use a third party called SwipeView.
It's an extension of the HorizontalScrollView class.
USE THIS , its working fine and no delays
hor = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
hor.postDelayed(new Runnable() {
public void run() {
hor.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
}
}, 1L);