public class WebView extends AbsoluteLayout implements ViewTreeObserver.OnGlobalFocusChangeListener, ViewGroup.OnHierarchyChangeListener, ViewDebug.HierarchyHandler
A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
Note that, in order for your Activity to access the Internet and load web pages
in a WebView, you must add the INTERNET
permissions to your
Android Manifest file:
<uses-permission android:name="android.permission.INTERNET" />
This must be a child of the <manifest>
element.
For more information, read Building Web Apps in WebView.
By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won't need to interact with the web page beyond reading it, and the web page won't need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView. For example:
Uri uri = Uri.parse("http://www.example.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
See Intent
for more information.
To provide a WebView in your own Activity, include a <WebView>
in your layout,
or set the entire Activity window as a WebView during onCreate()
:
WebView webview = new WebView(this); setContentView(webview);
Then load the desired web page:
// Simplest usage: note that an exception will NOT be thrown // if there is an error loading this page (see below). webview.loadUrl("http://slashdot.org/"); // OR, you can also load from an HTML string: String summary = "<html><body>You scored <b>192</b> points.</body></html>"; webview.loadData(summary, "text/html", null); // ... although note that there are restrictions on what this HTML can do. // See the JavaDocs forloadData()
andloadDataWithBaseURL()
for more info.
A WebView has several customization points where you can add your own behavior. These are:
WebChromeClient
subclass.
This class is called when something that might impact a
browser UI happens, for instance, progress updates and
JavaScript alerts are sent here (see Debugging Tasks).
WebViewClient
subclass.
It will be called when things happen that impact the
rendering of the content, eg, errors or form submissions. You
can also intercept URL loading here (via shouldOverrideUrlLoading()
).WebSettings
, such as
enabling JavaScript with setJavaScriptEnabled()
. addJavascriptInterface(java.lang.Object, java.lang.String)
method. This
method allows you to inject Java objects into a page's JavaScript
context, so that they can be accessed by JavaScript in the page.Here's a more complicated example, showing error handling, settings, and progress notification:
// Let's display the progress in the activity title bar, like the // browser app does. getWindow().requestFeature(Window.FEATURE_PROGRESS); webview.getSettings().setJavaScriptEnabled(true); final Activity activity = this; webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { // Activities and WebViews measure progress with different scales. // The progress meter will automatically disappear when we reach 100% activity.setProgress(progress * 1000); } }); webview.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show(); } }); webview.loadUrl("http://developer.android.com/");
To enable the built-in zoom, set
WebSettings
.WebSettings.setBuiltInZoomControls(boolean)
(introduced in API level Build.VERSION_CODES.CUPCAKE
).
NOTE: Using zoom if either the height or width is set to
ViewGroup.LayoutParams.WRAP_CONTENT
may lead to undefined behavior
and should be avoided.
For obvious security reasons, your application has its own cache, cookie store etc.—it does not share the Browser application's data.
By default, requests by the HTML to open new windows are
ignored. This is true whether they be opened by JavaScript or by
the target attribute on a link. You can customize your
WebChromeClient
to provide your own behaviour for opening multiple windows,
and render them in whatever manner you want.
The standard behavior for an Activity is to be destroyed and
recreated when the device orientation or any other configuration changes. This will cause
the WebView to reload the current page. If you don't want that, you
can set your Activity to handle the orientation
and keyboardHidden
changes, and then just leave the WebView alone. It'll automatically
re-orient itself as appropriate. Read Handling Runtime Changes for
more information about how to handle configuration changes during runtime.
The screen density of a device is based on the screen resolution. A screen with low density has fewer available pixels per inch, where a screen with high density has more — sometimes significantly more — pixels per inch. The density of a screen is important because, other things being equal, a UI element (such as a button) whose height and width are defined in terms of screen pixels will appear larger on the lower density screen and smaller on the higher density screen. For simplicity, Android collapses all actual screen densities into three generalized densities: high, medium, and low.
By default, WebView scales a web page so that it is drawn at a size that matches the default
appearance on a medium density screen. So, it applies 1.5x scaling on a high density screen
(because its pixels are smaller) and 0.75x scaling on a low density screen (because its pixels
are bigger).
Starting with API level Build.VERSION_CODES.ECLAIR
, WebView supports DOM, CSS,
and meta tag features to help you (as a web developer) target screens with different screen
densities.
Here's a summary of the features you can use to handle different screen densities:
window.devicePixelRatio
DOM property. The value of this property specifies the
default scaling factor used for the current device. For example, if the value of window.devicePixelRatio
is "1.0", then the device is considered a medium density (mdpi) device
and default scaling is not applied to the web page; if the value is "1.5", then the device is
considered a high density device (hdpi) and the page content is scaled 1.5x; if the
value is "0.75", then the device is considered a low density device (ldpi) and the content is
scaled 0.75x.-webkit-device-pixel-ratio
CSS media query. Use this to specify the screen
densities for which this style sheet is to be used. The corresponding value should be either
"0.75", "1", or "1.5", to indicate that the styles are for devices with low density, medium
density, or high density screens, respectively. For example:
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1.5)" href="hdpi.css" />
The hdpi.css
stylesheet is only used for devices with a screen pixel ration of 1.5,
which is the high density pixel ratio.
In order to support inline HTML5 video in your application you need to have hardware acceleration turned on.
In order to support full screen — for video or other HTML content — you need to set a
WebChromeClient
and implement both
WebChromeClient.onShowCustomView(View, WebChromeClient.CustomViewCallback)
and WebChromeClient.onHideCustomView()
. If the implementation of either of these two methods is
missing then the web contents will not be allowed to enter full screen. Optionally you can implement
WebChromeClient.getVideoLoadingProgressView()
to customize the View displayed whilst a video
is loading.
For applications targeting Android N and later releases
(API level > Build.VERSION_CODES.M
) the geolocation api is only supported on
secure origins such as https. For such applications requests to geolocation api on non-secure
origins are automatically denied without invoking the corresponding
WebChromeClient.onGeolocationPermissionsShowPrompt(String, GeolocationPermissions.Callback)
method.
It is recommended to set the WebView layout height to a fixed value or to
ViewGroup.LayoutParams.MATCH_PARENT
instead of using
ViewGroup.LayoutParams.WRAP_CONTENT
.
When using ViewGroup.LayoutParams.MATCH_PARENT
for the height none of the WebView's parents should use a
ViewGroup.LayoutParams.WRAP_CONTENT
layout height since that could result in
incorrect sizing of the views.
Setting the WebView's height to ViewGroup.LayoutParams.WRAP_CONTENT
enables the following behaviors:
Build.VERSION_CODES.KITKAT
and earlier SDKs the
HTML viewport meta tag will be ignored in order to preserve backwards compatibility.
Using a layout width of ViewGroup.LayoutParams.WRAP_CONTENT
is not
supported. If such a width is used the WebView will attempt to use the width of the parent
instead.
WebView may upload anonymous diagnostic data to Google when the user has consented. This data helps Google improve WebView. Data is collected on a per-app basis for each app which has instantiated a WebView. An individual app can opt out of this feature by putting the following tag in its manifest:
<meta-data android:name="android.webkit.WebView.MetricsOptOut" android:value="true" />
Data will only be uploaded for a given app if the user has consented AND the app has not opted out.
Modifier and Type | Class and Description |
---|---|
static interface |
WebView.FindListener
Interface to listen for find results.
|
static class |
WebView.HitTestResult |
static interface |
WebView.PictureListener
Deprecated.
This interface is now obsolete.
|
class |
WebView.PrivateAccess
Callback interface, allows the provider implementation to access non-public methods
and fields, and make super-class calls in this WebView instance.
|
static class |
WebView.VisualStateCallback
Callback interface supplied to
postVisualStateCallback(long, android.webkit.WebView.VisualStateCallback) for receiving
notifications about the visual state. |
class |
WebView.WebViewTransport
Transportation object for returning WebView across thread boundaries.
|
AbsoluteLayout.LayoutParams
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
Modifier and Type | Field and Description |
---|---|
static String |
DATA_REDUCTION_PROXY_SETTING_CHANGED
Broadcast Action: Indicates the data reduction proxy setting changed.
|
static String |
SCHEME_GEO
URI scheme for map address.
|
static String |
SCHEME_MAILTO
URI scheme for email address.
|
static String |
SCHEME_TEL
URI scheme for telephone number.
|
CLIP_TO_PADDING_MASK, DEBUG_DRAW, FLAG_DISALLOW_INTERCEPT, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_DEFAULT, LAYOUT_MODE_OPTICAL_BOUNDS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, SYSTEM_UI_TRANSPARENT, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
Modifier | Constructor and Description |
---|---|
|
WebView(Context context)
Constructs a new WebView with a Context object.
|
|
WebView(Context context,
AttributeSet attrs)
Constructs a new WebView with layout parameters.
|
|
WebView(Context context,
AttributeSet attrs,
int defStyleAttr)
Constructs a new WebView with layout parameters and a default style.
|
|
WebView(Context context,
AttributeSet attrs,
int defStyleAttr,
boolean privateBrowsing)
Deprecated.
Private browsing is no longer supported directly via
WebView and will be removed in a future release. Prefer using
WebSettings , WebViewDatabase , CookieManager
and WebStorage for fine-grained control of privacy data. |
|
WebView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Constructs a new WebView with layout parameters and a default style.
|
protected |
WebView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes,
Map<String,Object> javaScriptInterfaces,
boolean privateBrowsing) |
protected |
WebView(Context context,
AttributeSet attrs,
int defStyleAttr,
Map<String,Object> javaScriptInterfaces,
boolean privateBrowsing)
Constructs a new WebView with layout parameters, a default style and a set
of custom Javscript interfaces to be added to this WebView at initialization
time.
|
Modifier and Type | Method and Description |
---|---|
void |
addJavascriptInterface(Object object,
String name)
Injects the supplied Java object into this WebView.
|
boolean |
canGoBack()
Gets whether this WebView has a back history item.
|
boolean |
canGoBackOrForward(int steps)
Gets whether the page can go back or forward the given
number of steps.
|
boolean |
canGoForward()
Gets whether this WebView has a forward history item.
|
boolean |
canZoomIn()
Deprecated.
This method is prone to inaccuracy due to race conditions
between the web rendering and UI threads; prefer
WebViewClient.onScaleChanged(android.webkit.WebView, float, float) . |
boolean |
canZoomOut()
Deprecated.
This method is prone to inaccuracy due to race conditions
between the web rendering and UI threads; prefer
WebViewClient.onScaleChanged(android.webkit.WebView, float, float) . |
Picture |
capturePicture()
Deprecated.
Use
onDraw(android.graphics.Canvas) to obtain a bitmap snapshot of the WebView, or
saveWebArchive(java.lang.String) to save the content to a file. |
void |
clearCache(boolean includeDiskFiles)
Clears the resource cache.
|
static void |
clearClientCertPreferences(Runnable onCleared)
Clears the client certificate preferences stored in response
to proceeding/cancelling client cert requests.
|
void |
clearFormData()
Removes the autocomplete popup from the currently focused form field, if
present.
|
void |
clearHistory()
Tells this WebView to clear its internal back/forward list.
|
void |
clearMatches()
Clears the highlighting surrounding text matches created by
findAllAsync(java.lang.String) . |
void |
clearSslPreferences()
Clears the SSL preferences table stored in response to proceeding with
SSL certificate errors.
|
void |
clearView()
Deprecated.
Use WebView.loadUrl("about:blank") to reliably reset the view state
and release page resources (including any running JavaScript).
|
protected int |
computeHorizontalScrollOffset()
Compute the horizontal offset of the horizontal scrollbar's thumb
within the horizontal range.
|
protected int |
computeHorizontalScrollRange()
Compute the horizontal range that the horizontal scrollbar
represents.
|
void |
computeScroll()
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
|
protected int |
computeVerticalScrollExtent()
Compute the vertical extent of the vertical scrollbar's thumb
within the vertical range.
|
protected int |
computeVerticalScrollOffset()
Compute the vertical offset of the vertical scrollbar's thumb
within the horizontal range.
|
protected int |
computeVerticalScrollRange()
Compute the vertical range that the vertical scrollbar represents.
|
WebBackForwardList |
copyBackForwardList()
Gets the WebBackForwardList for this WebView.
|
PrintDocumentAdapter |
createPrintDocumentAdapter()
Deprecated.
Use
createPrintDocumentAdapter(String) which requires user
to provide a print document name. |
PrintDocumentAdapter |
createPrintDocumentAdapter(String documentName)
Creates a PrintDocumentAdapter that provides the content of this Webview for printing.
|
WebMessagePort[] |
createWebMessageChannel()
Creates a message channel to communicate with JS and returns the message
ports that represent the endpoints of this message channel.
|
void |
debugDump()
Deprecated.
This method is now obsolete.
|
void |
destroy()
Destroys the internal state of this WebView.
|
static void |
disablePlatformNotifications()
Deprecated.
This method is now obsolete.
|
protected void |
dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
|
boolean |
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
|
void |
documentHasImages(Message response)
Queries the document to see if it contains any image references.
|
void |
dumpViewHierarchyWithProperties(BufferedWriter out,
int level)
See
ViewDebug.HierarchyHandler#dumpViewHierarchyWithProperties(BufferedWriter, int) |
void |
emulateShiftHeld()
Deprecated.
This method is now obsolete.
|
static void |
enablePlatformNotifications()
Deprecated.
This method is now obsolete.
|
static void |
enableSlowWholeDocumentDraw()
For apps targeting the L release, WebView has a new default behavior that reduces
memory footprint and increases performance by intelligently choosing
the portion of the HTML document that needs to be drawn.
|
protected void |
encodeProperties(ViewHierarchyEncoder encoder) |
void |
evaluateJavascript(String script,
ValueCallback<String> resultCallback)
Asynchronously evaluates JavaScript in the context of the currently displayed page.
|
static String |
findAddress(String addr)
Gets the first substring consisting of the address of a physical
location.
|
int |
findAll(String find)
Deprecated.
findAllAsync(java.lang.String) is preferred. |
void |
findAllAsync(String find)
Finds all instances of find on the page and highlights them,
asynchronously.
|
View |
findFocus()
Find the view in the hierarchy rooted at this view that currently has
focus.
|
View |
findHierarchyView(String className,
int hashCode)
See
ViewDebug.HierarchyHandler#findHierarchyView(String, int) |
void |
findNext(boolean forward)
Highlights and scrolls to the next match found by
findAllAsync(java.lang.String) , wrapping around page boundaries as necessary. |
void |
flingScroll(int vx,
int vy) |
void |
freeMemory()
Deprecated.
Memory caches are automatically dropped when no longer needed, and in response
to system memory pressure.
|
static void |
freeMemoryForTests()
Used only by internal tests to free up memory.
|
CharSequence |
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
|
AccessibilityNodeProvider |
getAccessibilityNodeProvider()
Gets the provider for managing a virtual view hierarchy rooted at this View
and reported to
AccessibilityService s
that explore the window content. |
SslCertificate |
getCertificate()
Gets the SSL certificate for the main top-level page or null if there is
no certificate (the site is not secure).
|
int |
getContentHeight()
Gets the height of the HTML content.
|
int |
getContentWidth()
Gets the width of the HTML content.
|
Bitmap |
getFavicon()
Gets the favicon for the current page.
|
Handler |
getHandler() |
WebView.HitTestResult |
getHitTestResult()
Gets a HitTestResult based on the current cursor node.
|
String[] |
getHttpAuthUsernamePassword(String host,
String realm)
Retrieves HTTP authentication credentials for a given host and realm.
|
String |
getOriginalUrl()
Gets the original URL for the current page.
|
static PluginList |
getPluginList()
Deprecated.
This was used for Gears, which has been deprecated.
|
int |
getProgress()
Gets the progress for the current page.
|
float |
getScale()
Deprecated.
This method is prone to inaccuracy due to race conditions
between the web rendering and UI threads; prefer
WebViewClient.onScaleChanged(android.webkit.WebView, float, float) . |
WebSettings |
getSettings()
Gets the WebSettings object used to control the settings for this
WebView.
|
String |
getTitle()
Gets the title for the current page.
|
String |
getTouchIconUrl()
Gets the touch icon URL for the apple-touch-icon element, or
a URL on this site's server pointing to the standard location of a
touch icon.
|
String |
getUrl()
Gets the URL for the current page.
|
int |
getVisibleTitleHeight()
Deprecated.
This method is now obsolete.
|
WebViewProvider |
getWebViewProvider()
Gets the WebViewProvider.
|
View |
getZoomControls()
Deprecated.
the built-in zoom mechanisms are preferred
|
void |
goBack()
Goes back in the history of this WebView.
|
void |
goBackOrForward(int steps)
Goes to the history item that is the number of steps away from
the current item.
|
void |
goForward()
Goes forward in the history of this WebView.
|
void |
invokeZoomPicker()
Invokes the graphical zoom picker widget for this WebView.
|
boolean |
isPaused()
Gets whether this WebView is paused, meaning onPause() was called.
|
boolean |
isPrivateBrowsingEnabled()
Gets whether private browsing is enabled in this WebView.
|
void |
loadData(String data,
String mimeType,
String encoding)
Loads the given data into this WebView using a 'data' scheme URL.
|
void |
loadDataWithBaseURL(String baseUrl,
String data,
String mimeType,
String encoding,
String historyUrl)
Loads the given data into this WebView, using baseUrl as the base URL for
the content.
|
void |
loadUrl(String url)
Loads the given URL.
|
void |
loadUrl(String url,
Map<String,String> additionalHttpHeaders)
Loads the given URL with the specified additional HTTP headers.
|
void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
Receive the result from a previous call to
View.startActivityForResult(Intent, int) . |
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
void |
onChildViewAdded(View parent,
View child)
Deprecated.
WebView no longer needs to implement
ViewGroup.OnHierarchyChangeListener. This method does nothing now.
|
void |
onChildViewRemoved(View p,
View child)
Deprecated.
WebView no longer needs to implement
ViewGroup.OnHierarchyChangeListener. This method does nothing now.
|
protected void |
onConfigurationChanged(Configuration newConfig)
Called when the current configuration of the resources being used
by the application have changed.
|
InputConnection |
onCreateInputConnection(EditorInfo outAttrs)
Create a new InputConnection for an InputMethod to interact
with the view.
|
protected void |
onDetachedFromWindowInternal()
This is a framework-internal mirror of onDetachedFromWindow() that's called
after onDetachedFromWindow().
|
boolean |
onDragEvent(DragEvent event)
Handles drag events sent by the system following a call to
startDragAndDrop() . |
protected void |
onDraw(Canvas canvas)
Implement this to do your drawing.
|
protected void |
onDrawVerticalScrollBar(Canvas canvas,
Drawable scrollBar,
int l,
int t,
int r,
int b)
Draw the vertical scrollbar if
View.isVerticalScrollBarEnabled()
returns true. |
void |
onFinishTemporaryDetach()
Called after
View.onStartTemporaryDetach() when the container is done
changing the view. |
protected void |
onFocusChanged(boolean focused,
int direction,
Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
|
boolean |
onGenericMotionEvent(MotionEvent event)
Implement this method to handle generic motion events.
|
void |
onGlobalFocusChanged(View oldFocus,
View newFocus)
Deprecated.
WebView should not have implemented
ViewTreeObserver.OnGlobalFocusChangeListener. This method does nothing now.
|
boolean |
onHoverEvent(MotionEvent event)
Implement this method to handle hover events.
|
void |
onInitializeAccessibilityEventInternal(AccessibilityEvent event) |
void |
onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) |
boolean |
onKeyDown(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyDown() : perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable. |
boolean |
onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyMultiple() : always returns false (doesn't handle
the event). |
boolean |
onKeyUp(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyUp() : perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER , KeyEvent.KEYCODE_ENTER
or KeyEvent.KEYCODE_SPACE is released. |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the
measured height.
|
protected void |
onOverScrolled(int scrollX,
int scrollY,
boolean clampedX,
boolean clampedY)
Called by
View.overScrollBy(int, int, int, int, int, int, int, int, boolean) to
respond to the results of an over-scroll operation. |
void |
onPause()
Does a best-effort attempt to pause any processing that can be paused
safely, such as animations and geolocation.
|
void |
onProvideVirtualStructure(ViewStructure structure)
Called when assist structure is being retrieved from a view as part of
Activity.onProvideAssistData to
generate additional virtual structure under this view. |
void |
onResume()
Resumes a WebView after a previous call to
onPause() . |
protected void |
onScrollChanged(int l,
int t,
int oldl,
int oldt)
This is called in response to an internal scroll in this view (i.e., the
view scrolled its own contents).
|
protected void |
onSizeChanged(int w,
int h,
int ow,
int oh)
This is called during layout when the size of this view has changed.
|
void |
onStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with
ViewGroup.detachViewFromParent . |
boolean |
onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
|
boolean |
onTrackballEvent(MotionEvent event)
Implement this method to handle trackball motion events.
|
protected void |
onVisibilityChanged(View changedView,
int visibility)
Called when the visibility of the view or an ancestor of the view has
changed.
|
void |
onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus.
|
protected void |
onWindowVisibilityChanged(int visibility)
Called when the window containing has change its visibility
(between
View.GONE , View.INVISIBLE , and View.VISIBLE ). |
boolean |
overlayHorizontalScrollbar()
Deprecated.
This method is now obsolete.
|
boolean |
overlayVerticalScrollbar()
Deprecated.
This method is now obsolete.
|
boolean |
pageDown(boolean bottom)
Scrolls the contents of this WebView down by half the page size.
|
boolean |
pageUp(boolean top)
Scrolls the contents of this WebView up by half the view size.
|
void |
pauseTimers()
Pauses all layout, parsing, and JavaScript timers for all WebViews.
|
boolean |
performAccessibilityActionInternal(int action,
Bundle arguments) |
boolean |
performLongClick()
Calls this view's OnLongClickListener, if it is defined.
|
void |
postUrl(String url,
byte[] postData)
Loads the URL with postData using "POST" method into this WebView.
|
void |
postVisualStateCallback(long requestId,
WebView.VisualStateCallback callback)
Posts a
WebView.VisualStateCallback , which will be called when
the current state of the WebView is ready to be drawn. |
void |
postWebMessage(WebMessage message,
Uri targetOrigin)
Post a message to main frame.
|
void |
refreshPlugins(boolean reloadOpenPages)
Deprecated.
This was used for Gears, which has been deprecated.
|
void |
reload()
Reloads the current URL.
|
void |
removeJavascriptInterface(String name)
Removes a previously injected Java object from this WebView.
|
boolean |
requestChildRectangleOnScreen(View child,
Rect rect,
boolean immediate)
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
|
boolean |
requestFocus(int direction,
Rect previouslyFocusedRect)
Call this to try to give focus to a specific view or to one of its descendants
and give it hints about the direction and a specific rectangle that the focus
is coming from.
|
void |
requestFocusNodeHref(Message hrefMsg)
Requests the anchor or image element URL at the last tapped point.
|
void |
requestImageRef(Message msg)
Requests the URL of the image last touched by the user. msg will be sent
to its target with a String representing the URL as its object.
|
boolean |
restorePicture(Bundle b,
File src)
Deprecated.
This method is now obsolete.
|
WebBackForwardList |
restoreState(Bundle inState)
Restores the state of this WebView from the given Bundle.
|
void |
resumeTimers()
Resumes all layout, parsing, and JavaScript timers for all WebViews.
|
void |
savePassword(String host,
String username,
String password)
Deprecated.
Saving passwords in WebView will not be supported in future versions.
|
boolean |
savePicture(Bundle b,
File dest)
Deprecated.
This method is now obsolete.
|
WebBackForwardList |
saveState(Bundle outState)
Saves the state of this WebView used in
Activity.onSaveInstanceState(android.os.Bundle) . |
void |
saveWebArchive(String filename)
Saves the current view as a web archive.
|
void |
saveWebArchive(String basename,
boolean autoname,
ValueCallback<String> callback)
Saves the current view as a web archive.
|
void |
setBackgroundColor(int color)
Sets the background color for this view.
|
void |
setCertificate(SslCertificate certificate)
Deprecated.
Calling this function has no useful effect, and will be
ignored in future releases.
|
void |
setDownloadListener(DownloadListener listener)
Registers the interface to be used when content can not be handled by
the rendering engine, and should be downloaded instead.
|
void |
setFindListener(WebView.FindListener listener)
Registers the listener to be notified as find-on-page operations
progress.
|
protected boolean |
setFrame(int left,
int top,
int right,
int bottom)
Assign a size and position to this view.
|
void |
setHorizontalScrollbarOverlay(boolean overlay)
Deprecated.
This method has no effect.
|
void |
setHttpAuthUsernamePassword(String host,
String realm,
String username,
String password)
Stores HTTP authentication credentials for a given host and realm.
|
void |
setInitialScale(int scaleInPercent)
Sets the initial scale for this WebView. 0 means default.
|
void |
setLayerType(int layerType,
Paint paint)
Specifies the type of layer backing this view.
|
void |
setLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view.
|
void |
setMapTrackballToArrowKeys(boolean setMap)
Deprecated.
Only the default case, true, will be supported in a future version.
|
void |
setNetworkAvailable(boolean networkUp)
Informs WebView of the network state.
|
void |
setOverScrollMode(int mode)
Set the over-scroll mode for this view.
|
void |
setPictureListener(WebView.PictureListener listener)
Deprecated.
This method is now obsolete.
|
void |
setScrollBarStyle(int style)
Specify the style of the scrollbars.
|
void |
setVerticalScrollbarOverlay(boolean overlay)
Deprecated.
This method has no effect.
|
void |
setWebChromeClient(WebChromeClient client)
Sets the chrome handler.
|
static void |
setWebContentsDebuggingEnabled(boolean enabled)
Enables debugging of web contents (HTML / CSS / JavaScript)
loaded into any WebViews of this application.
|
void |
setWebViewClient(WebViewClient client)
Sets the WebViewClient that will receive various notifications and
requests.
|
boolean |
shouldDelayChildPressedState()
Deprecated.
|
boolean |
showFindDialog(String text,
boolean showIme)
Deprecated.
This method does not work reliably on all Android versions;
implementing a custom find dialog using WebView.findAllAsync()
provides a more robust solution.
|
void |
stopLoading()
Stops the current load.
|
void |
zoomBy(float zoomFactor)
Performs a zoom operation in this WebView.
|
boolean |
zoomIn()
Performs zoom in in this WebView.
|
boolean |
zoomOut()
Performs zoom out in this WebView.
|
checkLayoutParams, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, onLayout
addChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addTransientView, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, buildTouchDispatchChildList, canAnimate, captureTransitioningViews, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, createSnapshot, damageChild, damageChildDeferred, damageChildInParent, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchActivityResult, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findNamedViews, findViewByAccessibilityIdTraversal, findViewByPredicateTraversal, findViewsWithText, findViewTraversal, findViewWithTagTraversal, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasFocus, hasFocusable, hasHoveredChild, hasTransientState, indexOfChild, internalSetPadding, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isShowingContextMenuWithCoords, isTransformedTouchPointInView, isTransitionGroup, jumpDrawablesToCurrentState, layout, makeOptionalFitsSystemWindows, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onChildVisibilityChanged, onCreateDrawableState, onDebugDraw, onDebugDrawMargins, onDetachedFromWindow, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onRequestSendAccessibilityEventInternal, onResolvePointerIcon, onSetLayoutParams, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestDisallowInterceptTouchEvent, requestSendAccessibilityEvent, requestTransitionStart, requestTransparentRegion, resetResolvedDrawables, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout
addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeOpaqueFlags, computeSystemWindowInsets, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, damageInParent, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, encode, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasShadow, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isAccessibilitySelectionExtendable, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onCloseSystemDialogs, onCreateContextMenu, onDisplayHint, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFocusLost, onHoverChanged, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyLongPress, onKeyPreIme, onKeyShortcut, onPopulateAccessibilityEvent, onPopulateAccessibilityEventInternal, onProvideStructure, onRenderNodeDetached, onResolveDrawables, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onSetAlpha, onVisibilityAggregated, onWindowSystemUiVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetRtlProperties, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventInternal, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilitySelection, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayoutDirection, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, requestFitSystemWindows, requestLayout
public static final String DATA_REDUCTION_PROXY_SETTING_CHANGED
public static final String SCHEME_TEL
public static final String SCHEME_MAILTO
public static final String SCHEME_GEO
public WebView(Context context)
context
- a Context object used to access application assetspublic WebView(Context context, AttributeSet attrs)
context
- a Context object used to access application assetsattrs
- an AttributeSet passed to our parentpublic WebView(Context context, AttributeSet attrs, int defStyleAttr)
context
- a Context object used to access application assetsattrs
- an AttributeSet passed to our parentdefStyleAttr
- an attribute in the current theme that contains a
reference to a style resource that supplies default values for
the view. Can be 0 to not look for defaults.public WebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
context
- a Context object used to access application assetsattrs
- an AttributeSet passed to our parentdefStyleAttr
- an attribute in the current theme that contains a
reference to a style resource that supplies default values for
the view. Can be 0 to not look for defaults.defStyleRes
- a resource identifier of a style resource that
supplies default values for the view, used only if
defStyleAttr is 0 or can not be found in the theme. Can be 0
to not look for defaults.@Deprecated public WebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing)
WebSettings
, WebViewDatabase
, CookieManager
and WebStorage
for fine-grained control of privacy data.context
- a Context object used to access application assetsattrs
- an AttributeSet passed to our parentdefStyleAttr
- an attribute in the current theme that contains a
reference to a style resource that supplies default values for
the view. Can be 0 to not look for defaults.privateBrowsing
- whether this WebView will be initialized in
private modeprotected WebView(Context context, AttributeSet attrs, int defStyleAttr, Map<String,Object> javaScriptInterfaces, boolean privateBrowsing)
context
- a Context object used to access application assetsattrs
- an AttributeSet passed to our parentdefStyleAttr
- an attribute in the current theme that contains a
reference to a style resource that supplies default values for
the view. Can be 0 to not look for defaults.javaScriptInterfaces
- a Map of interface names, as keys, and
object implementing those interfaces, as
valuesprivateBrowsing
- whether this WebView will be initialized in
private modeprotected WebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes, Map<String,Object> javaScriptInterfaces, boolean privateBrowsing)
@Deprecated public void setHorizontalScrollbarOverlay(boolean overlay)
overlay
- true if horizontal scrollbar should have overlay style@Deprecated public void setVerticalScrollbarOverlay(boolean overlay)
overlay
- true if vertical scrollbar should have overlay style@Deprecated public boolean overlayHorizontalScrollbar()
@Deprecated public boolean overlayVerticalScrollbar()
public int getVisibleTitleHeight()
public SslCertificate getCertificate()
@Deprecated public void setCertificate(SslCertificate certificate)
@Deprecated public void savePassword(String host, String username, String password)
host
- the host that required the credentialsusername
- the username for the given hostpassword
- the password for the given hostWebViewDatabase.clearUsernamePassword()
,
WebViewDatabase.hasUsernamePassword()
public void setHttpAuthUsernamePassword(String host, String realm, String username, String password)
WebViewClient.onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String)
.host
- the host to which the credentials applyrealm
- the realm to which the credentials applyusername
- the usernamepassword
- the passwordgetHttpAuthUsernamePassword(java.lang.String, java.lang.String)
,
WebViewDatabase.hasHttpAuthUsernamePassword()
,
WebViewDatabase.clearHttpAuthUsernamePassword()
public String[] getHttpAuthUsernamePassword(String host, String realm)
WebViewClient.onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String)
.host
- the host to which the credentials applyrealm
- the realm to which the credentials applysetHttpAuthUsernamePassword(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
WebViewDatabase.hasHttpAuthUsernamePassword()
,
WebViewDatabase.clearHttpAuthUsernamePassword()
public void destroy()
@Deprecated public static void enablePlatformNotifications()
@Deprecated public static void disablePlatformNotifications()
public static void freeMemoryForTests()
public void setNetworkAvailable(boolean networkUp)
networkUp
- a boolean indicating if network is availablepublic WebBackForwardList saveState(Bundle outState)
Activity.onSaveInstanceState(android.os.Bundle)
. Please note that this
method no longer stores the display data for this WebView. The previous
behavior could potentially leak files if restoreState(android.os.Bundle)
was never
called.outState
- the Bundle to store this WebView's state@Deprecated public boolean savePicture(Bundle b, File dest)
saveState(android.os.Bundle)
.b
- a Bundle to store the display datadest
- the file to store the serialized picture data. Will be
overwritten with this WebView's picture data.@Deprecated public boolean restorePicture(Bundle b, File src)
savePicture(android.os.Bundle, java.io.File)
. Used in
conjunction with restoreState(android.os.Bundle)
. Note that this will not work if
this WebView is hardware accelerated.b
- a Bundle containing the saved display datasrc
- the file where the picture data was storedpublic WebBackForwardList restoreState(Bundle inState)
Activity.onRestoreInstanceState(android.os.Bundle)
and should be called to restore the state of this WebView. If
it is called after this WebView has had a chance to build state (load
pages, create a back/forward list, etc.) there may be undesirable
side-effects. Please note that this method no longer restores the
display data for this WebView.inState
- the incoming Bundle of statepublic void loadUrl(String url, Map<String,String> additionalHttpHeaders)
Also see compatibility note on evaluateJavascript(java.lang.String, android.webkit.ValueCallback<java.lang.String>)
.
url
- the URL of the resource to loadadditionalHttpHeaders
- the additional headers to be used in the
HTTP request for this URL, specified as a map from name to
value. Note that if this map contains any of the headers
that are set by default by this WebView, such as those
controlling caching, accept types or the User-Agent, their
values may be overriden by this WebView's defaults.public void loadUrl(String url)
Also see compatibility note on evaluateJavascript(java.lang.String, android.webkit.ValueCallback<java.lang.String>)
.
url
- the URL of the resource to loadpublic void postUrl(String url, byte[] postData)
loadUrl(String)
instead, ignoring the postData param.url
- the URL of the resource to loadpostData
- the data will be passed to "POST" request, which must be
be "application/x-www-form-urlencoded" encoded.public void loadData(String data, String mimeType, String encoding)
Note that JavaScript's same origin policy means that script running in a
page loaded using this method will be unable to access content loaded
using any scheme other than 'data', including 'http(s)'. To avoid this
restriction, use loadDataWithBaseURL()
with an appropriate base URL.
The encoding parameter specifies whether the data is base64 or URL encoded. If the data is base64 encoded, the value of the encoding parameter must be 'base64'. For all other values of the parameter, including null, it is assumed that the data uses ASCII encoding for octets inside the range of safe URL characters and use the standard %xx hex encoding of URLs for octets outside that range. For example, '#', '%', '\', '?' should be replaced by %23, %25, %27, %3f respectively.
The 'data' scheme URL formed by this method uses the default US-ASCII
charset. If you need need to set a different charset, you should form a
'data' scheme URL which explicitly specifies a charset parameter in the
mediatype portion of the URL and call loadUrl(String)
instead.
Note that the charset obtained from the mediatype portion of a data URL
always overrides that specified in the HTML or XML document itself.
data
- a String of data in the given encodingmimeType
- the MIME type of the data, e.g. 'text/html'encoding
- the encoding of the datapublic void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)
Note that content specified in this way can access local device files (via 'file' scheme URLs) only if baseUrl specifies a scheme other than 'http', 'https', 'ftp', 'ftps', 'about' or 'javascript'.
If the base URL uses the data scheme, this method is equivalent to
calling loadData()
and the
historyUrl is ignored, and the data will be treated as part of a data: URL.
If the base URL uses any other scheme, then the data will be loaded into
the WebView as a plain string (i.e. not part of a data URL) and any URL-encoded
entities in the string will not be decoded.
Note that the baseUrl is sent in the 'Referer' HTTP header when requesting subresources (images, etc.) of the page loaded using this method.
baseUrl
- the URL to use as the page's base URL. If null defaults to
'about:blank'.data
- a String of data in the given encodingmimeType
- the MIMEType of the data, e.g. 'text/html'. If null,
defaults to 'text/html'.encoding
- the encoding of the datahistoryUrl
- the URL to use as the history entry. If null defaults
to 'about:blank'. If non-null, this must be a valid URL.public void evaluateJavascript(String script, ValueCallback<String> resultCallback)
Compatibility note. Applications targeting Build.VERSION_CODES.N
or
later, JavaScript state from an empty WebView is no longer persisted across navigations like
loadUrl(String)
. For example, global variables and functions defined before calling
loadUrl(String)
will not exist in the loaded page. Applications should use
addJavascriptInterface(java.lang.Object, java.lang.String)
instead to persist JavaScript objects across navigations.
script
- the JavaScript to execute.resultCallback
- A callback to be invoked when the script execution
completes with the result of the execution (if any).
May be null if no notificaion of the result is required.public void saveWebArchive(String filename)
filename
- the filename where the archive should be placedpublic void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback)
basename
- the filename where the archive should be placedautoname
- if false, takes basename to be a file. If true, basename
is assumed to be a directory in which a filename will be
chosen according to the URL of the current page.callback
- called after the web archive has been saved. The
parameter for onReceiveValue will either be the filename
under which the file was saved, or null if saving the
file failed.public void stopLoading()
public void reload()
public boolean canGoBack()
public void goBack()
public boolean canGoForward()
public void goForward()
public boolean canGoBackOrForward(int steps)
steps
- the negative or positive number of steps to move the
historypublic void goBackOrForward(int steps)
steps
- the number of steps to take back or forward in the back
forward listpublic boolean isPrivateBrowsingEnabled()
public boolean pageUp(boolean top)
top
- true to jump to the top of the pagepublic boolean pageDown(boolean bottom)
bottom
- true to jump to bottom of pagepublic void postVisualStateCallback(long requestId, WebView.VisualStateCallback callback)
WebView.VisualStateCallback
, which will be called when
the current state of the WebView is ready to be drawn.
Because updates to the the DOM are processed asynchronously, updates to the DOM may not
immediately be reflected visually by subsequent onDraw(android.graphics.Canvas)
invocations. The
WebView.VisualStateCallback
provides a mechanism to notify the caller when the contents of
the DOM at the current time are ready to be drawn the next time the WebView
draws.
The next draw after the callback completes is guaranteed to reflect all the updates to the
DOM up to the the point at which the WebView.VisualStateCallback
was posted, but it may also
contain updates applied after the callback was posted.
The state of the DOM covered by this API includes the following:
To guarantee that the WebView
will successfully render the first frame
after the WebView.VisualStateCallback.onComplete(long)
method has been called a set of conditions
must be met:
WebView
's visibility is set to VISIBLE
then
the WebView
must be attached to the view hierarchy.WebView
's visibility is set to INVISIBLE
then the WebView
must be attached to the view hierarchy and must be made
VISIBLE
from the WebView.VisualStateCallback.onComplete(long)
method.WebView
's visibility is set to GONE
then the
WebView
must be attached to the view hierarchy and its
LayoutParams
's width and height need to be set to fixed
values and must be made VISIBLE
from the
WebView.VisualStateCallback.onComplete(long)
method.When using this API it is also recommended to enable pre-rasterization if the WebView
is offscreen to avoid flickering. See WebSettings.setOffscreenPreRaster(boolean)
for
more details and do consider its caveats.
requestId
- An id that will be returned in the callback to allow callers to match
requests with callbacks.callback
- The callback to be invoked.@Deprecated public void clearView()
@Deprecated public Picture capturePicture()
onDraw(android.graphics.Canvas)
to obtain a bitmap snapshot of the WebView, or
saveWebArchive(java.lang.String)
to save the content to a file.
Note that due to internal changes, for API levels between
Build.VERSION_CODES.HONEYCOMB
and
Build.VERSION_CODES.ICE_CREAM_SANDWICH
inclusive, the
picture does not include fixed position elements or scrollable divs.
Note that from Build.VERSION_CODES.JELLY_BEAN_MR1
the returned picture
should only be drawn into bitmap-backed Canvas - using any other type of Canvas will involve
additional conversion at a cost in memory and performance. Also the
Picture.createFromStream(java.io.InputStream)
and
Picture.writeToStream(java.io.OutputStream)
methods are not supported on the
returned object.
@Deprecated public PrintDocumentAdapter createPrintDocumentAdapter()
createPrintDocumentAdapter(String)
which requires user
to provide a print document name.public PrintDocumentAdapter createPrintDocumentAdapter(String documentName)
PrintDocumentAdapter
for more information.documentName
- The user-facing name of the printed document. See
PrintDocumentInfo
@Deprecated public float getScale()
WebViewClient.onScaleChanged(android.webkit.WebView, float, float)
.public void setInitialScale(int scaleInPercent)
WebSettings.getUseWideViewPort()
and
WebSettings.getLoadWithOverviewMode()
.
If the content fits into the WebView control by width, then
the zoom is set to 100%. For wide content, the behavor
depends on the state of WebSettings.getLoadWithOverviewMode()
.
If its value is true, the content will be zoomed out to be fit
by width into the WebView control, otherwise not.
If initial scale is greater than 0, WebView starts with this value
as initial scale.
Please note that unlike the scale properties in the viewport meta tag,
this method doesn't take the screen density into account.scaleInPercent
- the initial scale in percentpublic void invokeZoomPicker()
public WebView.HitTestResult getHitTestResult()
requestFocusNodeHref(android.os.Message)
asynchronously. If a HTML::img tag is
found, the HitTestResult type is set to IMAGE_TYPE and the URL is set in
the "extra" field. A type of
SRC_IMAGE_ANCHOR_TYPE indicates an anchor with a URL that has an image as
a child node. If a phone number is found, the HitTestResult type is set
to PHONE_TYPE and the phone number is set in the "extra" field of
HitTestResult. If a map address is found, the HitTestResult type is set
to GEO_TYPE and the address is set in the "extra" field of HitTestResult.
If an email address is found, the HitTestResult type is set to EMAIL_TYPE
and the email is set in the "extra" field of HitTestResult. Otherwise,
HitTestResult type is set to UNKNOWN_TYPE.public void requestFocusNodeHref(Message hrefMsg)
hrefMsg
- the message to be dispatched with the result of the
request. The message data contains three keys. "url"
returns the anchor's href attribute. "title" returns the
anchor's text. "src" returns the image's src attribute.public void requestImageRef(Message msg)
msg
- the message to be dispatched with the result of the request
as the data member with "url" as key. The result can be null.public String getUrl()
public String getOriginalUrl()
public String getTitle()
public Bitmap getFavicon()
public String getTouchIconUrl()
public int getProgress()
public int getContentHeight()
public int getContentWidth()
public void pauseTimers()
public void resumeTimers()
public void onPause()
pauseTimers()
.
To resume WebView, call onResume()
.public void onResume()
onPause()
.public boolean isPaused()
@Deprecated public void freeMemory()
public void clearCache(boolean includeDiskFiles)
includeDiskFiles
- if false, only the RAM cache is clearedpublic void clearFormData()
WebViewDatabase.clearFormData()
.public void clearHistory()
public void clearSslPreferences()
public static void clearClientCertPreferences(Runnable onCleared)
KeyChain.ACTION_STORAGE_CHANGED
intent. The preferences are
shared by all the webviews that are created by the embedder application.onCleared
- A runnable to be invoked when client certs are cleared.
The embedder can pass null if not interested in the
callback. The runnable will be called in UI thread.public WebBackForwardList copyBackForwardList()
public void setFindListener(WebView.FindListener listener)
listener
- an implementation of WebView.FindListener
public void findNext(boolean forward)
findAllAsync(java.lang.String)
, wrapping around page boundaries as necessary.
Notifies any registered WebView.FindListener
. If findAllAsync(String)
has not been called yet, or if clearMatches()
has been called since the
last find operation, this function does nothing.forward
- the direction to searchsetFindListener(android.webkit.WebView.FindListener)
@Deprecated public int findAll(String find)
findAllAsync(java.lang.String)
is preferred.WebView.FindListener
.find
- the string to findsetFindListener(android.webkit.WebView.FindListener)
public void findAllAsync(String find)
WebView.FindListener
.
Successive calls to this will cancel any pending searches.find
- the string to find.setFindListener(android.webkit.WebView.FindListener)
@Deprecated public boolean showFindDialog(String text, boolean showIme)
text
- if non-null, will be the initial text to search for.
Otherwise, the last String searched for in this WebView will
be used to start.showIme
- if true, show the IME, assuming the user will begin typing.
If false and text is non-null, perform a find all.public static String findAddress(String addr)
addr
- the string to search for addressespublic static void enableSlowWholeDocumentDraw()
onDraw(android.graphics.Canvas)
to do own drawing and accesses portions
of the page that is way outside the visible portion of the page.capturePicture()
to capture a very large HTML document.
Note that capturePicture is a deprecated API.public void clearMatches()
findAllAsync(java.lang.String)
.public void documentHasImages(Message response)
response
- the message that will be dispatched with the resultpublic void setWebViewClient(WebViewClient client)
client
- an implementation of WebViewClientpublic void setDownloadListener(DownloadListener listener)
listener
- an implementation of DownloadListenerpublic void setWebChromeClient(WebChromeClient client)
client
- an implementation of WebChromeClient@Deprecated public void setPictureListener(WebView.PictureListener listener)
listener
- an implementation of WebView.PictureListenerpublic void addJavascriptInterface(Object object, String name)
Build.VERSION_CODES.JELLY_BEAN_MR1
and above, only public methods that are annotated with
JavascriptInterface
can be accessed from JavaScript.
For applications targeted to API level Build.VERSION_CODES.JELLY_BEAN
or below,
all public methods (including the inherited ones) can be accessed, see the
important security note below for implications.
Note that injected objects will not appear in JavaScript until the page is next (re)loaded. For example:
class JsObject { @JavascriptInterface public String toString() { return "injectedObject"; } } webView.addJavascriptInterface(new JsObject(), "injectedObject"); webView.loadData("", "text/html", null); webView.loadUrl("javascript:alert(injectedObject.toString())");
IMPORTANT:
Build.VERSION_CODES.JELLY_BEAN
or earlier.
Apps that target a version later than Build.VERSION_CODES.JELLY_BEAN
are still vulnerable if the app runs on a device running Android earlier than 4.2.
The most secure way to use this method is to target Build.VERSION_CODES.JELLY_BEAN_MR1
and to ensure the method is called only when running on Android 4.2 or later.
With these older versions, JavaScript could use reflection to access an
injected object's public fields. Use of this method in a WebView
containing untrusted content could allow an attacker to manipulate the
host application in unintended ways, executing Java code with the
permissions of the host application. Use extreme care when using this
method in a WebView which could contain untrusted content.Build.VERSION_CODES.LOLLIPOP
and above, methods of injected Java objects are enumerable from
JavaScript.object
- the Java object to inject into this WebView's JavaScript
context. Null values are ignored.name
- the name used to expose the object in JavaScriptpublic void removeJavascriptInterface(String name)
addJavascriptInterface(java.lang.Object, java.lang.String)
.name
- the name used to expose the object in JavaScriptpublic WebMessagePort[] createWebMessageChannel()
The returned message channels are entangled and already in started state.
public void postWebMessage(WebMessage message, Uri targetOrigin)
message
- the WebMessagetargetOrigin
- the target origin. This is the origin of the page
that is intended to receive the message. For best security
practices, the user should not specify a wildcard (*) when
specifying the origin.public WebSettings getSettings()
public static void setWebContentsDebuggingEnabled(boolean enabled)
enabled
- whether to enable web contents debugging@Deprecated public static PluginList getPluginList()
@Deprecated public void refreshPlugins(boolean reloadOpenPages)
@Deprecated public void emulateShiftHeld()
@Deprecated public void onChildViewAdded(View parent, View child)
ViewGroup.OnHierarchyChangeListener
onChildViewAdded
in interface ViewGroup.OnHierarchyChangeListener
parent
- the view in which a child was addedchild
- the new child view added in the hierarchy@Deprecated public void onChildViewRemoved(View p, View child)
ViewGroup.OnHierarchyChangeListener
onChildViewRemoved
in interface ViewGroup.OnHierarchyChangeListener
p
- the view from which the child was removedchild
- the child removed from the hierarchy@Deprecated public void onGlobalFocusChanged(View oldFocus, View newFocus)
ViewTreeObserver.OnGlobalFocusChangeListener
onGlobalFocusChanged
in interface ViewTreeObserver.OnGlobalFocusChangeListener
oldFocus
- The previously focused view, if any.newFocus
- The newly focused View, if any.@Deprecated public void setMapTrackballToArrowKeys(boolean setMap)
public void flingScroll(int vx, int vy)
@Deprecated public View getZoomControls()
Build.VERSION_CODES.CUPCAKE
introduced
built-in zoom mechanisms for the WebView, as opposed to these separate
zoom controls. The built-in mechanisms are preferred and can be enabled
using WebSettings.setBuiltInZoomControls(boolean)
.@Deprecated public boolean canZoomIn()
WebViewClient.onScaleChanged(android.webkit.WebView, float, float)
.@Deprecated public boolean canZoomOut()
WebViewClient.onScaleChanged(android.webkit.WebView, float, float)
.public void zoomBy(float zoomFactor)
zoomFactor
- the zoom factor to apply. The zoom factor will be clamped to the Webview's
zoom limits. This value must be in the range 0.01 to 100.0 inclusive.public boolean zoomIn()
public boolean zoomOut()
@Deprecated public void debugDump()
public void dumpViewHierarchyWithProperties(BufferedWriter out, int level)
ViewDebug.HierarchyHandler#dumpViewHierarchyWithProperties(BufferedWriter, int)
dumpViewHierarchyWithProperties
in interface ViewDebug.HierarchyHandler
out
- The output writerlevel
- The indentation levelpublic View findHierarchyView(String className, int hashCode)
ViewDebug.HierarchyHandler#findHierarchyView(String, int)
findHierarchyView
in interface ViewDebug.HierarchyHandler
className
- The className of the view to findhashCode
- The hashCode of the view to findpublic WebViewProvider getWebViewProvider()
protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class ViewGroup
View.onDetachedFromWindow()
protected void onDetachedFromWindowInternal()
View
onDetachedFromWindowInternal
in class View
public void setLayoutParams(ViewGroup.LayoutParams params)
View
setLayoutParams
in class View
params
- The layout parameters for this view, cannot be nullpublic void setOverScrollMode(int mode)
View
View.OVER_SCROLL_ALWAYS
(default), View.OVER_SCROLL_IF_CONTENT_SCROLLS
(allow over-scrolling only if the view content is larger than the container),
or View.OVER_SCROLL_NEVER
.
Setting the over-scroll mode of a view will have an effect only if the
view is capable of scrolling.setOverScrollMode
in class View
mode
- The new over-scroll mode for this view.public void setScrollBarStyle(int style)
View
Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
setScrollBarStyle
in class View
style
- the style of the scrollbars. Should be one of
SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET,
SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.View.SCROLLBARS_INSIDE_OVERLAY
,
View.SCROLLBARS_INSIDE_INSET
,
View.SCROLLBARS_OUTSIDE_OVERLAY
,
View.SCROLLBARS_OUTSIDE_INSET
protected int computeHorizontalScrollRange()
View
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollExtent()
and
View.computeHorizontalScrollOffset()
.
The default range is the drawing width of this view.
computeHorizontalScrollRange
in class View
View.computeHorizontalScrollExtent()
,
View.computeHorizontalScrollOffset()
,
ScrollBarDrawable
protected int computeHorizontalScrollOffset()
View
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollRange()
and
View.computeHorizontalScrollExtent()
.
The default offset is the scroll offset of this view.
computeHorizontalScrollOffset
in class View
View.computeHorizontalScrollRange()
,
View.computeHorizontalScrollExtent()
,
ScrollBarDrawable
protected int computeVerticalScrollRange()
View
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollExtent()
and
View.computeVerticalScrollOffset()
.
computeVerticalScrollRange
in class View
The default range is the drawing height of this view.
View.computeVerticalScrollExtent()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
protected int computeVerticalScrollOffset()
View
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollRange()
and
View.computeVerticalScrollExtent()
.
The default offset is the scroll offset of this view.
computeVerticalScrollOffset
in class View
View.computeVerticalScrollRange()
,
View.computeVerticalScrollExtent()
,
ScrollBarDrawable
protected int computeVerticalScrollExtent()
View
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollRange()
and
View.computeVerticalScrollOffset()
.
The default extent is the drawing height of this view.
computeVerticalScrollExtent
in class View
View.computeVerticalScrollRange()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
public void computeScroll()
View
Scroller
object.computeScroll
in class View
public boolean onHoverEvent(MotionEvent event)
View
This method is called whenever a pointer is hovering into, over, or out of the
bounds of a view and the view is not currently being touched.
Hover events are represented as pointer events with action
MotionEvent.ACTION_HOVER_ENTER
, MotionEvent.ACTION_HOVER_MOVE
,
or MotionEvent.ACTION_HOVER_EXIT
.
MotionEvent.ACTION_HOVER_ENTER
when the pointer enters the bounds of the view.MotionEvent.ACTION_HOVER_MOVE
when the pointer has already entered the bounds of the view and has moved.MotionEvent.ACTION_HOVER_EXIT
when the pointer has exited the bounds of the view or when the pointer is
about to go down due to a button click, tap, or similar user action that
causes the view to be touched.The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.
The default implementation calls View.setHovered(boolean)
to update the hovered state
of the view when a hover enter or hover exit event is received, if the view
is enabled and is clickable. The default implementation also sends hover
accessibility events.
onHoverEvent
in class View
event
- The motion event that describes the hover.View.isHovered()
,
View.setHovered(boolean)
,
View.onHoverChanged(boolean)
public boolean onTouchEvent(MotionEvent event)
View
If this method is used to detect click actions, it is recommended that
the actions be performed by implementing and calling
View.performClick()
. This will ensure consistent system behavior,
including:
ACTION_CLICK
when
accessibility features are enabled
onTouchEvent
in class View
event
- The motion event.public boolean onGenericMotionEvent(MotionEvent event)
View
Generic motion events describe joystick movements, mouse hovers, track pad
touches, scroll wheel movements and other input events. The
source
of the motion event specifies
the class of input that was received. Implementations of this method
must examine the bits in the source before processing the event.
The following code example shows how this is done.
Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER
are delivered to the view under the pointer. All other generic motion events are
delivered to the focused view.
public boolean onGenericMotionEvent(MotionEvent event) { if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { if (event.getAction() == MotionEvent.ACTION_MOVE) { // process the joystick movement... return true; } } if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { switch (event.getAction()) { case MotionEvent.ACTION_HOVER_MOVE: // process the mouse hover movement... return true; case MotionEvent.ACTION_SCROLL: // process the scroll wheel movement... return true; } } return super.onGenericMotionEvent(event); }
onGenericMotionEvent
in class View
event
- The generic motion event being processed.public boolean onTrackballEvent(MotionEvent event)
View
MotionEvent.getX()
and
MotionEvent.getY()
. These are normalized so
that a movement of 1 corresponds to the user pressing one DPAD key (so
they will often be fractional values, representing the more fine-grained
movement information available from a trackball).onTrackballEvent
in class View
event
- The motion event.public boolean onKeyDown(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyDown()
: perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER
or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyDown
in interface KeyEvent.Callback
onKeyDown
in class View
keyCode
- a key code that represents the button pressed, from
KeyEvent
event
- the KeyEvent object that defines the button actionpublic boolean onKeyUp(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyUp()
: perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER
, KeyEvent.KEYCODE_ENTER
or KeyEvent.KEYCODE_SPACE
is released.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyUp
in interface KeyEvent.Callback
onKeyUp
in class View
keyCode
- A key code that represents the button pressed, from
KeyEvent
.event
- The KeyEvent object that defines the button action.public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
View
KeyEvent.Callback.onKeyMultiple()
: always returns false (doesn't handle
the event).
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyMultiple
in interface KeyEvent.Callback
onKeyMultiple
in class View
keyCode
- A key code that represents the button pressed, from
KeyEvent
.repeatCount
- The number of times the action was made.event
- The KeyEvent object that defines the button action.public AccessibilityNodeProvider getAccessibilityNodeProvider()
View
AccessibilityService
s
that explore the window content.
If this method returns an instance, this instance is responsible for managing
AccessibilityNodeInfo
s describing the virtual sub-tree rooted at this
View including the one representing the View itself. Similarly the returned
instance is responsible for performing accessibility actions on any virtual
view or the root view itself.
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(AccessibilityDelegate)
its
View.AccessibilityDelegate.getAccessibilityNodeProvider(View)
is responsible for handling this call.
getAccessibilityNodeProvider
in class View
AccessibilityNodeProvider
@Deprecated public boolean shouldDelayChildPressedState()
ViewGroup
shouldDelayChildPressedState
in class AbsoluteLayout
public CharSequence getAccessibilityClassName()
View
AccessibilityNodeInfo.setClassName
.getAccessibilityClassName
in class ViewGroup
public void onProvideVirtualStructure(ViewStructure structure)
View
Activity.onProvideAssistData
to
generate additional virtual structure under this view. The defaullt implementation
uses View.getAccessibilityNodeProvider()
to try to generate this from the
view's virtual accessibility nodes, if any. You can override this for a more
optimal implementation providing this data.onProvideVirtualStructure
in class View
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info)
onInitializeAccessibilityNodeInfoInternal
in class ViewGroup
Note: Called from the default {@link AccessibilityDelegate}.
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event)
onInitializeAccessibilityEventInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
public boolean performAccessibilityActionInternal(int action, Bundle arguments)
performAccessibilityActionInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
protected void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, int l, int t, int r, int b)
View
Draw the vertical scrollbar if View.isVerticalScrollBarEnabled()
returns true.
onDrawVerticalScrollBar
in class View
canvas
- the canvas on which to draw the scrollbarscrollBar
- the scrollbar's drawableView.isVerticalScrollBarEnabled()
,
View.computeVerticalScrollRange()
,
View.computeVerticalScrollExtent()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY)
View
View.overScrollBy(int, int, int, int, int, int, int, int, boolean)
to
respond to the results of an over-scroll operation.onOverScrolled
in class View
scrollX
- New X scroll value in pixelsscrollY
- New Y scroll value in pixelsclampedX
- True if scrollX was clamped to an over-scroll boundaryclampedY
- True if scrollY was clamped to an over-scroll boundaryprotected void onWindowVisibilityChanged(int visibility)
View
View.GONE
, View.INVISIBLE
, and View.VISIBLE
). Note
that this tells you whether or not your window is being made visible
to the window manager; this does not tell you whether or not
your window is obscured by other windows on the screen, even if it
is itself visible.onWindowVisibilityChanged
in class View
visibility
- The new visibility of the window.protected void onDraw(Canvas canvas)
View
public boolean performLongClick()
View
performLongClick
in class View
true
if one of the above receivers consumed the event,
false
otherwiseprotected void onConfigurationChanged(Configuration newConfig)
View
Activity
mechanism of
recreating the activity instance upon a configuration change.onConfigurationChanged
in class View
newConfig
- The new resource configuration.public InputConnection onCreateInputConnection(EditorInfo outAttrs)
View
When implementing this, you probably also want to implement
View.onCheckIsTextEditor()
to indicate you will return a
non-null InputConnection.
Also, take good care to fill in the EditorInfo
object correctly and in its entirety, so that the connected IME can rely
on its values. For example, EditorInfo.initialSelStart
and EditorInfo.initialSelEnd
members
must be filled in with the correct cursor position for IMEs to work correctly
with your application.
onCreateInputConnection
in class View
outAttrs
- Fill in with attribute information about the connection.public boolean onDragEvent(DragEvent event)
View
startDragAndDrop()
.
When the system calls this method, it passes a
DragEvent
object. A call to
DragEvent.getAction()
returns one of the action type constants defined
in DragEvent. The method uses these to determine what is happening in the drag and drop
operation.
onDragEvent
in class View
event
- The DragEvent
sent by the system.
The DragEvent.getAction()
method returns an action type constant defined
in DragEvent, indicating the type of drag event represented by this object.true
if the method was successful, otherwise false
.
The method should return true
in response to an action type of
DragEvent.ACTION_DRAG_STARTED
to receive drag events for the current
operation.
The method should also return true
in response to an action type of
DragEvent.ACTION_DROP
if it consumed the drop, or
false
if it didn't.
protected void onVisibilityChanged(View changedView, int visibility)
View
onVisibilityChanged
in class View
changedView
- The view whose visibility changed. May be
this
or an ancestor view.visibility
- The new visibility, one of View.VISIBLE
,
View.INVISIBLE
or View.GONE
.public void onWindowFocusChanged(boolean hasWindowFocus)
View
onWindowFocusChanged
in class View
hasWindowFocus
- True if the window containing this view now has
focus, false otherwise.protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
View
onFocusChanged
in class View
focused
- True if the View has focus; false otherwise.direction
- The direction focus has moved when requestFocus()
is called to give this view focus. Values are
View.FOCUS_UP
, View.FOCUS_DOWN
, View.FOCUS_LEFT
,
View.FOCUS_RIGHT
, View.FOCUS_FORWARD
, or View.FOCUS_BACKWARD
.
It may not always apply, in which case use the default.previouslyFocusedRect
- The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null
otherwise.protected boolean setFrame(int left, int top, int right, int bottom)
View
protected void onSizeChanged(int w, int h, int ow, int oh)
View
onSizeChanged
in class View
w
- Current width of this view.h
- Current height of this view.ow
- Old width of this view.oh
- Old height of this view.protected void onScrollChanged(int l, int t, int oldl, int oldt)
View
View.scrollBy(int, int)
or View.scrollTo(int, int)
having been
called.onScrollChanged
in class View
l
- Current horizontal scroll origin.t
- Current vertical scroll origin.oldl
- Previous horizontal scroll origin.oldt
- Previous vertical scroll origin.public boolean dispatchKeyEvent(KeyEvent event)
View
dispatchKeyEvent
in class ViewGroup
event
- The key event to be dispatched.public boolean requestFocus(int direction, Rect previouslyFocusedRect)
ViewGroup
View.isFocusable()
returns
false), or if it is focusable and it is not focusable in touch mode
(View.isFocusableInTouchMode()
) while the device is in touch mode.
A View will not take focus if it is not visible.
A View will not take focus if one of its parents has
ViewGroup.getDescendantFocusability()
equal to
ViewGroup.FOCUS_BLOCK_DESCENDANTS
.
See also View.focusSearch(int)
, which is what you call to say that you
have focus, and you want your parent to look for the next one.
You may wish to override this method if your custom View
has an internal
View
that it wishes to forward the request to.
Looks for a view to give focus to respecting the setting specified by
ViewGroup.getDescendantFocusability()
.
Uses ViewGroup.onRequestFocusInDescendants(int, android.graphics.Rect)
to
find focus within the children of this group when appropriate.requestFocus
in class ViewGroup
direction
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpreviouslyFocusedRect
- The rectangle (in this View's coordinate system)
to give a finer grained hint about where focus is coming from. May be null
if there is no hint.ViewGroup.FOCUS_BEFORE_DESCENDANTS
,
ViewGroup.FOCUS_AFTER_DESCENDANTS
,
ViewGroup.FOCUS_BLOCK_DESCENDANTS
,
ViewGroup.onRequestFocusInDescendants(int, android.graphics.Rect)
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int)
and
should be overridden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call View.setMeasuredDimension(int, int)
to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
View.measure(int, int)
. Calling the superclass'
View.onMeasure(int, int)
is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int)
to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight()
and
View.getSuggestedMinimumWidth()
).
onMeasure
in class AbsoluteLayout
widthMeasureSpec
- horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.heightMeasureSpec
- vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.View.getMeasuredWidth()
,
View.getMeasuredHeight()
,
View.setMeasuredDimension(int, int)
,
View.getSuggestedMinimumHeight()
,
View.getSuggestedMinimumWidth()
,
View.MeasureSpec.getMode(int)
,
View.MeasureSpec.getSize(int)
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate)
ViewParent
ViewGroup
s overriding this can trust
that:
ViewGroup
s overriding this should uphold the contract:
requestChildRectangleOnScreen
in interface ViewParent
requestChildRectangleOnScreen
in class ViewGroup
child
- The direct child making the request.rect
- The rectangle in the child's coordinates the child
wishes to be on the screen.immediate
- True to forbid animated or delayed scrolling,
false otherwisepublic void setBackgroundColor(int color)
View
setBackgroundColor
in class View
color
- the color of the backgroundpublic void setLayerType(int layerType, Paint paint)
View
Specifies the type of layer backing this view. The layer can be
View.LAYER_TYPE_NONE
, View.LAYER_TYPE_SOFTWARE
or
View.LAYER_TYPE_HARDWARE
.
A layer is associated with an optional Paint
instance that controls how the layer is composed on screen. The following
properties of the paint are taken into account when composing the layer:
If this view has an alpha value set to < 1.0 by calling
View.setAlpha(float)
, the alpha value of the layer's paint is superseded
by this view's alpha value.
Refer to the documentation of View.LAYER_TYPE_NONE
,
View.LAYER_TYPE_SOFTWARE
and View.LAYER_TYPE_HARDWARE
for more information on when and how to use layers.
setLayerType
in class View
layerType
- The type of layer to use with this view, must be one of
View.LAYER_TYPE_NONE
, View.LAYER_TYPE_SOFTWARE
or
View.LAYER_TYPE_HARDWARE
paint
- The paint used to compose the layer. This argument is optional
and can be null. It is ignored when the layer type is
View.LAYER_TYPE_NONE
View.getLayerType()
,
View.LAYER_TYPE_NONE
,
View.LAYER_TYPE_SOFTWARE
,
View.LAYER_TYPE_HARDWARE
,
View.setAlpha(float)
protected void dispatchDraw(Canvas canvas)
View
dispatchDraw
in class ViewGroup
canvas
- the canvas on which to draw the viewpublic void onStartTemporaryDetach()
View
ViewGroup.detachViewFromParent
.
It will either be followed by View.onFinishTemporaryDetach()
or
View.onDetachedFromWindow()
when the container is done.onStartTemporaryDetach
in class View
public void onFinishTemporaryDetach()
View
View.onStartTemporaryDetach()
when the container is done
changing the view.onFinishTemporaryDetach
in class View
public Handler getHandler()
getHandler
in class View
public View findFocus()
View
public void onActivityResult(int requestCode, int resultCode, Intent data)
View.startActivityForResult(Intent, int)
.onActivityResult
in class View
requestCode
- The integer request code originally supplied to
startActivityForResult(), allowing you to identify who this
result came from.resultCode
- The integer result code returned by the child activity
through its setResult().data
- An Intent, which can return result data to the caller
(various data can be attached to Intent "extras").protected void encodeProperties(ViewHierarchyEncoder encoder)
View
encodeProperties
in class ViewGroup