problemWhen loading an HTML page with an inline WebView in Android, an input box exists in the HTML page. Then in some mobile devices, when the input box gets focus, the system input keyboard does not eject correctly, thus unable to complete the normal input requirements
In doing the app, oneself also encountered this problem, the following is their own solution, there may not be suitable for everyone encountered situation, but it is worth learning ~
WebView Setup IssuesSometimes we design HTML page is not very good to adapt to webview, especially our HTML page is designed for the PC browser, when the use of WebView to load, the interface is likely to be confused, when the input box is covered by other elements (such as Div), Input will not pop up even though input can be displayed and selected. The only thing we can do in this situation is
1, Webview.getsettings (). Setusewideviewport (True), so that WebView can adapt to the phone screen size, free scaling, making WebView and PC browser more similar, Avoid interface layout confusion, reduce the probability of a problem 2, provide a mobile version of HTML
Code ErrorSometimes we need to customize the WebView to meet specific needs, such as we want to add a loading progress bar for WebView, to unify the display of WebView progress bar, then it is possible to appear the following code
public class Progressbarwebview extends webview{
Public Progressbarwebview (Context context) { This (context, NULL); } Public Progressbarwebview (context context, AttributeSet Attrs) { This (context, attrs, 0); } Public Progressbarwebview (context context, AttributeSet attrs, int defstyle) { Super (context, attrs, Defstyle); Todo Your code }
} |
What's wrong with this piece of code? When using Progressbarwebview, if you do not specify a style in layout, you will enter
Public Progressbarwebview (context context, AttributeSet Attrs) { This (context, attrs, 0); } |
Constructor method, here we specify 0, if go to see Android WebView source code, is defined as follows
Public WebView (context context, AttributeSet Attrs) { This (context, attrs, Com.android.internal.r.attr.webviewstyle); } |
COM must be attached for WebView.Android.Internal.R.attr.Webviewstyle style, otherwise webview not work properly
SummaryThe above is their own summary of some of the methods, I hope that everyone has help ~
Android WebView Input Box keyboard does not eject