Android WebView Input Box keyboard does not eject

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.