Android Development WebView Input box prompts solution _android

Source: Internet
Author: User

When based on WebView applications, there is an input box on the page, when the input text too much, more than the number of lines in the input box, the input box can scroll, the time problem comes, the input of the arrows will be moved to the input box, how to solve this problem, find chromium source code as follows:

void Loadifnecessary (Jobject context) {
if (loaded_) return
;
Loaded_ = true;
Trace_event0 ("Browser", "Handleresources::create");
jnienv* env = Base::android::attachcurrentthread ();
if (!context) Context
= Base::android::getapplicationcontext ();
LEFT_BITMAP_ = Createskbitmapfromjavabitmap (
java_handleviewresources_getlefthandlebitmap (env, context));
RIGHT_BITMAP_ = Createskbitmapfromjavabitmap (
java_handleviewresources_getrighthandlebitmap (env, context));
CENTER_BITMAP_ = Createskbitmapfromjavabitmap (
java_handleviewresources_getcenterhandlebitmap (env, context)) ;
Left_bitmap_.setimmutable ();
Right_bitmap_.setimmutable ();
Center_bitmap_.setimmutable ();
Drawable_horizontal_padding_ratio_ =
Java_handleviewresources_gethandlehorizontalpaddingratio (env);
}

This function loads these pictures, on the Java side,

private static Bitmap Gethandlebitmap (context context, final int[] attrs) {//TODO (Jdduke): properly derive and apply th
EME color.
TypedArray a = Context.gettheme (). Obtainstyledattributes (Attrs);
Final int resid = A.getresourceid (A.getindex (0), 0);
Final Resources res = a.getresources ();
A.recycle ();
Final Bitmap.config Config = Bitmap.Config.ARGB_8888;
Final Bitmapfactory.options Options = new Bitmapfactory.options ();
Options.injustdecodebounds = false;
options.inpreferredconfig = config;
Bitmap Bitmap = Bitmapfactory.decoderesource (res, resid, options);
Savepic (bitmap);
if (bitmap!= null) return bitmap;
If themed resource lookup fails, fall back to using the "context"//Resources for attribute lookup. if (res!= context.getresources ()) {bitmap = Bitmapfactory.decoderesource (Context.getresources (), resid, options); if (b
Itmap!= null) return bitmap;
} drawable drawable = gethandledrawable (context, attrs);
Assert drawable!= null; Final int width = drawable.getintrinsicwidth ();
Final int height = drawable.getintrinsicheight ();
Bitmap Canvasbitmap = bitmap.createbitmap (width, height, config);
Canvas Canvas = new Canvas (CANVASBITMAP);
Drawable.setbounds (0, 0, width, height);
Drawable.draw (canvas);
return canvasbitmap; }

In C + +, the function gethandlebitmap in Java is called, which is loaded by Context.gettheme (). obtainstyledattributes This function, loading the picture resource from the JDK, displaying the Get the image information through the GETBITMAP function, set the content displayed by Layer_->setbitmap (bitmap), the function is as follows:

Const skbitmap& Getbitmap (ui::touchhandleorientation orientation) {
Dcheck (loaded_);
Switch (orientation) {case
Ui::touchhandleorientation::left: return
left_bitmap_;
Case Ui::touchhandleorientation::right: Return
right_bitmap_;
Case Ui::touchhandleorientation::center: Return
center_bitmap_;
Case ui::touchhandleorientation::undefined:
notreached () << "Invalid touch handle orientation.";
return CENTER_BITMAP_;
}

So analysis, want to solve this problem from the display, it seems unlikely, that only replace the picture resources, and image resources in the Android.jar package, there are other ways? Analyze the source code,

public static drawable Getlefthandledrawable (context context) {return
gethandledrawable, Left_handle_ attrs);
}
public static drawable Getcenterhandledrawable (context context) {return
gethandledrawable, Center_handle _attrs);
}
public static drawable Getrighthandledrawable (context context) {return
gethandledrawable, Right_handle_ attrs);
}

There are several image ID information, can not overload it, so add your own

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<style name= "MyTheme" >
< Item Name= "Android:textselecthandleleft" > @drawable/ic_launcher</item>
<item name= "Android: Textselecthandle "> @drawable/aa</item>
<item name=" Android:textselecthandleright "> @drawable ic_launcher</item>
</style>
</resources>

Replace the resources of the system and add Android:theme= "@style/mytheme" own theme style, problem solving

Related Article

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.