How to stop android webview from wrapping content while zooming? - android

Android webview auto wraps content while zoom in and out. For example, while zooming in, it wraps one line of text to next line, and therefore the layout is changed. But what I want to achieve is only zooming in without changing any layout. How to achieve it?

Find the solution from here finally.
MyView.getSettings().setLoadWithOverviewMode(true);
MyView.getSettings().setUseWideViewPort(true);

Related

Ignore windowSoftInputMode for certain elements eg. Background Image

My question is, is there a way to get a certain view element to ignore the windowSoftInput setting, or to set a specific setting for one view element? (Any other solutions to my problem are also welcome)
Below are more details about my problem.
I have an Android activity with a background image set to the main FrameLayout. This layout contains a few other layouts, among others a brand logo on one side, and a scrollview with edittext boxes on the other side.
Using the windowSoftInput="adjustResize" works pretty well, but it distorts the background image. Using windowSoftInput="adjustPan" however pans the brand logo out of the screen and messes with the scrollview, and the keyboard blocks the edittext boxes.
So far, looking around the web and the docs I can't find a solution, or if this is even possible. Android layouts always seem to confuse me though..

Android window doesn't resize/pan when softinput opened from WebView

My problem is following.
Application uses theme android:Theme.NoTitleBar.Fullscreen and there is only one Activity, all other views are Fragment
I have WebView inside ViewPager Fragment which is inside ScrollView
HTML content has input fields
I click input field which is on bottom of WebView
Soft input opens, but the Window is not resized/panned
I've tried setting android:windowSoftInputMode="adjustResize" or android:windowSoftInputMode="adjustPan" in my manifest for the Activity. Also tried setting one of those in java.
Normal EditText inside a ScrollView in my application does adjust pan properly so user can see where he/she is typing.
UPDATE:
If there is no working solution to get window adjust, is there a way to get WebView think it's content is like half screen height more bigger so user could at least scroll the input visible.
Okay so this has been an issue from the very beginning and Google hasn't fixed it yet, maybe never. But from the the issue: http://code.google.com/p/android/issues/detail?id=5497 I found potential workaround for this: https://stackoverflow.com/a/19494006/1241783
I have overridden WebView and I simply added the code for it and it is working well enough to get the window adjusted. It is possible though the code doesn't always work because of various screen heights and might need some adjustments, but in many cases it is working okay and I go with that, since it's the only working solution I have seen.
Try this android:isScrollContainer="false" in the ScrollView. According to the Android docx.
Set this if the view will serve as a scrolling container, meaning that
it can be resized to shrink its overall window so that there will be
space for an input method
Hope this will solve your problem
Here is what we have done to make it work.
As it is by design, FLAG_FULLSCREEN activity won't allow adjusting the views when a keyboard is visible, we took an approach with custom Keyboard Notification Listener and OnTouch listener of Webview.
KeyboardHelper.java - to find out the keyboard visibility
Webview Full-Screen Activity Adjustment - To adjust the webview based on the notification and touch point.
Hope it helps!
my code was also not able to resize when keyboard opens.
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/simple_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
/>
i removed (android:scrollbars="none") statement, and it worked ! So that means the app resizes itself only when the container is scrollable. so by default webview containers scrollable area internally.

Android/Mobile Webkit CSS Background-Attachment:Fixed Not Working?

Am I just going crazy, or does background-attachment:fixed; really not work in the native Android browser?
I already implemented a simple fix by using two divs instead of one... The first div is positioned absolutely and contains the fixed background image, the other div goes on top of it and contains the scrolling content.
The issue with this fix (aside from the unnecessary complication) is that for some reason, when I am scrolling the content over the background image div, the background image disappears altogether! :(
Has anyone else found a workaround that isn't buggy, or how exactly are we supposed to work with this?
With native browser scrolling you cannot do that. It's a bug in the default Andriod browser. To implement a fixed element at the top or the bottom you have to apply position: fixed on it and then implement a custom scrolling on the other element which contains the content to scroll.
I used this Library for this kind of problems:
http://cubiq.org/iscroll-4
You can find examples on its page.

Android horizontal scroll programmatically

In Android, I want to create a particular control which may require to set the location of a component by fixed coordinates.
This is what I want to do. These screenshot are taken from a swing application of mine. I want to clone the buttons on top and their behaviour, into an android application. Basically if there are too many buttons in the menubar, left and/or right arrows appear, and clicking on them will scroll horizontally to access the hidden buttons.
I need to be able to set the coordinates of an horizontal linear layout inside another one, and even to set negative coordinates in order to scroll on the right.
I'm doing this using a null layout in swing. Can I achieve this with Android ?
I'm not sure if an HorizontalScrollView can do this. Could someone point out a good tutorial or something related to what I'd like to do.
I think a HorizontalScrollView can achieve what you intend to do with your Menu Bar. You don't need these "scroll" Buttons, because a user can swipe the menu.
You can nest LinearLayouts together, however you want. if you want to control their flow try to apply margins to them. You can set fixed Coordinates in an AbsoluteLayout, too.
Consider using a gallery? If not gallery, then a child or cousin of it. As far as I know, there is no ViewParent that will allow what your are shooting for.
Hope that helped ~Aedon

Orange rectangle around links in WebView

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().

Categories

Resources