Eclipse Android Webview, how to center the content - android

I am nearly done with my first app, but I am still working on some little issues.
My main problem is that I am loading a normal html page, but I have no access to the html code.
Now I want to center the page in the webview module, because the page is also centered, so that when I am loading the page, I have to scroll all the time to the right side and that is really anoying.
So how do I do that, that the webview modul automatically loads the page already centered and the user of the app sees the middle of the page?

You mean, you dont want horizontal scroll,for that try this :
mwebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

Related

When I move between the pages in the hybrid app, I can see the previous one for a seconds. And issue for changing CSS

I'm currently working on making hybrid-app.
(Using jquery mobile.)
I have some problems on rendering webview in the application.
There are lists and detail pages with html. when the transition happens, the screen displays white screen, a previous page for a seconds, white screen and then displays detail page. And it goes to the same when I click a back button.
is this a cache problem or hardware accelerate?
I separated css file from one whole one while the application was on service. And there was css rendering problem until i did "clear date" on mobile not "clear cache". CSS didn't seem like working at all on the page.
Is this a issue of jquery mobile? or is this also the cache problem? then why didn't it work when i did "clear cache" but "clear data"?
And what will happen if i put this?:
context.deleteDatabase("webview.db");
context.deleteDatabase("webviewCache.db");
will all data saved be deleted? like, settings people using now?
Two topics I noticed in the context of page transitions and jqm:
A) rendering of a page takes some time and have impact on the transition. If you generate/update your detailed page, wait until everything has finished before the page transition starts (can be achieved with setTimeout(..., 10)
B) unfortunately, all pages in jqm are scrolling together and are not independent from each other. I noticed that before a page transition starts, the current page is scrolled to the top. Afterwards the new page appears. Looks ugly... Unfortunately several css settings must be modified to change this behaviour.
Hope this helps,
Andreas

How to detect when the scrollbar has reached the top or bottom of webpage?

I am working with WebView and my problem is that whenever the scrollbar reaches to the end or top of WebView it should indicate this to me with some boolean value so that I can display the next and previous page correspondingly.
I am working on a project and I want to show a HTML file as a html reader so I want to know whenever the scrollbar reaches the end of webpage so I can load the further pages.
I do recommend you iScroll:
http://cubiq.org/iscroll-4
It's easy to use and it works fairly perfect on every mobile platforms.

Android - webview removing header and footer displaying only selected contents

i need to convert a complete website into an android app. But I don't want the header, menu and footer in every page to be displayed.
Is there any way I can just take the content of the webpage alone and display in web view.?
Thanks.
If you are using joomla...i have a solution that worked for me....
Go to template settings, hide the logo, menu and footer section
In your app you wll not see any header, footer and logo
Do you have control over the website's source? If yes, it is much easier to write a css-file for mobiles (and use JS to detect the UserAgent) than to do any of that work in the mobile app itself.
However, if you really want to mess with the page on your device, you can extract the html-source, change it (delete the header+menu+footer), and load that changed source into the webview.

How can I force a webview on Android to scroll to the top of the page?

I have a couple of html forms inside of an Android app.
To hide the background image of the app on the webview the height of the html page is set to 1000px via CSS (it's also set to 100% via Java for the webview, but that does not always work).
Problem:
Form A on page 1 is rather long, the submitbutton is at the end of the page. Form B on page 2 is short.
After posting form A the app does not scroll to the top of page 2 but stays at the same position. As post B is short the user sees nothing but the empty background. Not good.
We tried the following methods:
pageUp (from the Java SDK)
scrollTo() (from the Java SDK)
insert a "<a name="top"></a>" in the html code of the forms and use "window.location.hash="top" from within the app to address the anchor
The last way works almost everywhere but not on Samsung devices (reported as broken with Samsung S2 and Ace). Are there other options we might have missed?
We ended up removing the 1000px css hack.

How do you create the Browser layout (search bar on top, webview on bottom)?

I'm trying to mimic the default android Browser app layout, which has a "search_bar" on top and then a "webview" right below it. The user can scroll both items up, all the while the scroll bar only appears to the right of the webview (not both the webview and the search bar).
I've tried putting both the webview and the searchbar into a scrollview, but this shows the scrollbar next to the search_bar.
If you need to mimic the exact layout of default browser have a look at it's source code:
Where can I find Android source code online?
If you need only browser source have a look here:
https://android.googlesource.com/platform/packages/apps/Browser
From what I can see (a quick look at it) it is more complicated layout, but you may start analysing it from:
Browser\res\layout\browser_subwindow.xml
which directly includes WebView. This file is directly loaded by Tab... Go ahaed and analyse it on your own it is pretty simple as it is a regular Android application.
Hope it helps.

Categories

Resources