WebView input box prompt, webview input box
When using a WebView-based application, there is an input box on the page. when too many texts are input and the number of lines in the input box is exceeded, the input box can be rolled. This is a problem, the input prompt arrow will be moved out of the input box. How can this problem be solved? Find the 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 images on the java side,
Private static Bitmap getHandleBitmap (Context context, final int [] attrs ){
// TODO (jdduke): Properly derive and apply theme 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's
// Resources for attribute lookup.
If (res! = Context. getResources ()){
Bitmap = BitmapFactory. decodeResource (context. getResources (), resId, options );
If (bitmap! = 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 getHandleBitmap function in java is called. getTheme (). the obtainStyledAttributes function loads image resources from jdk. When the image is displayed, the GetBitmap function obtains the image information and sets the displayed content through 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 _;
}
After this analysis, it seems impossible to solve this problem from the perspective of display. Only image resources are replaced, while image resources are in the android. jar package. Is there any other way? Analyze source code,
Public static Drawable getLeftHandleDrawable (Context context ){
Return getHandleDrawable (context, LEFT_HANDLE_ATTRS );
}
Public static Drawable getCenterHandleDrawable (Context context ){
Return getHandleDrawable (context, CENTER_HANDLE_ATTRS );
}
Public static Drawable getRightHandleDrawable (Context context ){
Return getHandleDrawable (context, RIGHT_HANDLE_ATTRS );
}
Can I reload these image IDs so I can add my 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 system resources and add the android: theme = "@ style/MyTheme" theme style. The problem is solved.
Recommended: http://www.cnblogs.com/roucheng/p/androidservice.html