Orange rectangle around links in WebView - android

I have a web view that is loaded with an HTML that contains links.
when I switch to another activity (say to another tab in a tab
activity) and then switching back to it, the link is surrounded with
an orange rectangle. also happens in the GoogleAdView which really
makes it impossible to view.

Try this to prevent webview from drawing a focus rectangle when it is first focused
webView.getSettings().setNeedInitialFocus(false);

Try webView.setFocusableInTouchMode(false) - it worked for me. Also, read this link if you want to understand what drove me to this solution.
You should take into account though that this solution will make all text input boxes in your webpage unavailable...
Found another solution, but it requires access to the html itself. You need to set the following css property: -webkit-tap-highlight-color:rgba(0,0,0,0); This will not cause the problem with the input boxes.

It seems that the link in the WebView has the focus. Maybe you could avoid it by letting another view request the focus (anotherView.requestFocus();) in onResume() or onStart().

Related

Android WebView jumping to the bottom

I have a ScrollView with 20 WebViews inside (yes, I know it's heavy but right now it's the best solution I've found). The WebViews are used to display forum posts.
I'm getting a very weird behavior on my Nexus 4 (it doesn't happen on some other devices I've tested) which is driving me crazy.
I have the first post visible and just a little bit of the second one visible. Now I want to scroll and instead of starting scrolling by putting the finger in the first post I put the finger on the portion of the second post that is visible. The WebView of that second post immediately jumps to the bottom which is a very annoying behavior while scrolling.
If you feel appropriate I can record a video of this behavior and upload to YouTube or you can search for AndroidPIT in the Play Store and check the behavior yourself in the Forum section. I won't post the link to the Play Store to avoid being called a spammer.
Thanks in advance.
From comment: "Have you tried setting your webview to non focusable and non clickable as it appears as it's trying to display the entire content of the item you are pressing on as you scroll"
Apparently View#setFocusable (view.setFocusable(false)) worked.
Make sure that the scrolling is handled by the scrollview in stead of the webview. I believe setting the Webview.canscrollvertically to false might fix the problem, let me know if it helped.

Android: how to show the user which view is active

I have an activity with a WebView. I would like to give the possibility to the user to scroll from one WebView to another WebView (as it's done to Android desktop):
with something in the bottom which shows which screen is actually viewed. I have think about the ScrollView but maybe something else exists which easier to use.
what you want to use is the ViewPager
http://android-developers.blogspot.de/2011/08/horizontal-view-swiping-with-viewpager.html
To get an indicator which shows on what page the user is use:
http://jakewharton.com/viewpagerindicator/
An example how to use it is here:
http://blog.stylingandroid.com/archives/537

Properly Scrolling an EditText into view when focused

I've got an EditText, which is ultimately inside of a ScrollView. I've implemented a comment feature which takes you to a new activity, and automatically places focus in the edit text so that the user can immediately start writing his comment.
Unfortunately, it doesn't quite scroll the edittext into view, as you can see in the screenshot below:
I would like to see something more like this, where the EditText comes completely into view (see below). I already looked at the android:WindowSoftInputMode, and it seems like the default values should work ... and indeed, it does mostly work because it does scroll, just not enough.
So is there anything I can do to get the desired behavior? Thanks!
is your min SDK 3?
check this
Hope you have tried android:windowSoftInputMode="adjustPan" and check this.
I would give this a go.
You could also try to programatically use this on the onCreate() method of you activity.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
"SOFT_INPUT_ADJUST_PAN" adjustment option is set to have a window pan when an input method is shown, so it doesn't need to deal with resizing but just panned by the framework to ensure the current input focus is visible.

Is there a workaround for the Android browser bug with CSS-Position and clickable areas?

When you have some clickable content like <a>, <input> or <area> and before this you have an absolutely positioned element with a bigger z-index, there is the wrong behavior of 'click-through'.
I click on the area where the clickable element is behind the front element. In other browsers there is the right behavior that the click does not go through the front element. But only in Android Browser you can click through the front element and activate the element behind. This is a known bug and you cannot avoid it. It's even in newer versions (I test on 2.3.3 in the official Android emulator).
There are some workarounds described in some forums but none of them worked for me.
I tried to put an <iframe> or an <a> between front and back
I tried to change the DOM so maybe the browsers state is refreshed
I tried to have the back elements be positioned as well
None worked
I'm especially having problems with the image map's area elements.
Has anyone had the same issue and managed to work around it?
I'm specifically interested in solutions which are tested against image maps.
I am wondering about a few things here. First, what is the purpose of having an overlaid image and using the image maps? I see you're including jQuery - can you use the hover event with jQuery to change the orientation of the images and do the swap? What about attaching to the click event for the image map, and checking to see if the lightbox is open. If it is, then return false;.
Just trying to think out loud. Sometimes another take on it can be helpful.
This is a quick blindfolded reply, so let me know if I should expand/fix it further. The general idea being a CSS class for both the hover and focus events that disables pointer interaction.
yourElementClass:focus, yourElementClass:hover {
pointer-events: none;
}
Actually I've managed to avoid it by moving the objects below to let them be not visible.
But in cases similar to yours the only workaround that actually works is to manage all the clicks in jquery (especially the ones on the background) and to bind/unbind the clicks events on needs.
there are also some things that could help on some version/mobiles (but do not solve the problem)
the above item has background:rgba(0,0,0,0.1);
you should put a gif or png as background of the above element (as well as the background color as point 1)
using thouchstart instead of click as bind event sometimes helps.
the actual version of android/browser are not affected with this bug (or at least it never happen to me) but it could be nice to know the affected versions. If someone has a list.

scrolling vertically to a specific text part in a webview

I'm looking for a way to scroll a webview that a specific part of the contained text is shown.
Scrolling programmatically needs always an integer value of how far to scroll. Is there any possibility of retrieving the y-position of a specific text in that webview?
If you are the editor of the html content, you could simply use anchors inside the html :
The text I want to scroll to
and then simply use webview.loadurl("mywebpage.html#firstpart")
WebView has the findAll(String) and findNext() methods. They're not well documented though, and they seem to have some issues pre-froyo.
This thread in particular may help you give it a try, though. These find methods call native code, so it's not something you could easily override, I don't think. There might be something you could do with Javascript, but that's certainly not something I'm familiar with.

Categories

Resources