Android Components > Feature > Find In Page
A feature that provides Find in Page functionality.
Use Gradle to download the library from maven.mozilla.org (Setup repository):
implementation "org.mozilla.components:feature-findinpage:{latest-version}"
To use this feature you have to do two things:
1. Add the FindInPageBar
widget to you layout:
<mozilla.components.feature.findinpage.view.FindInPageBar
android:id="@+id/find_in_page"
android:layout_width="match_parent"
android:background="#FFFFFFFF"
android:elevation="10dp"
android:layout_height="56dp"
android:padding="4dp" />
These are the properties that you can customize of this widget.
<attr name="findInPageQueryTextColor" format="reference|color"/>
<attr name="findInPageQueryHintTextColor" format="reference|color"/>
<attr name="findInPageQueryTextSize" format="dimension"/>
<attr name="findInPageResultCountTextColor" format="reference|color"/>
<attr name="findInPageResultCountTextSize" format="dimension"/>
<attr name="findInPageButtonsTint" format="reference|color"/>
<attr name="findInPageNoMatchesTextColor" format="reference|color"/>
2. Add the FindInPageFeature
to your activity/fragment:
val findInPageBar = layout.findViewById<FindInPageBar>(R.id.find_in_page)
val findInPageFeature = FindInPageFeature(
sessionManager,
findInPageView
) {
// Optional: Handle clicking of "close" button.
}
lifecycle.addObservers(findInPageFeature)
// To show "Find in Page" results for a `Session`:
findInPageFeature.bind(session)
🦊 A practical example of using feature find in page can be found in Sample Browser.
This component emits the following Facts:
Action | Item | Extras | Description |
---|---|---|---|
CLICK | previous | The user clicked the previous result button. | |
CLICK | next | The user clicked the next result button. | |
CLICK | close | The user clicked the close button. | |
COMMIT | input | inputExtras |
The user committed a query to be found on the page. |
Key | Type | Value |
---|---|---|
value | String | The query that was searched |
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/