You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-source/src/en/library/android.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,39 @@ However, please inject before the `LayoutInflater` instance is used to load the
150
150
151
151
:::
152
152
153
+
#### Using the Patching Tool
154
+
155
+
You can use `PanguTextPatcher` to patch existing `View` or `ViewGroup` instances.
156
+
157
+
Patch the entire root layout, and `PanguTextPatcher` will automatically patch all `TextView` or its subclasses under the root layout.
158
+
159
+
> The following example
160
+
161
+
```kotlin
162
+
// Assume you have a root layout.
163
+
val root: ViewGroup
164
+
// Patch the root layout.
165
+
PanguTextPatcher.patch(root)
166
+
```
167
+
168
+
Patch a single `View`, which is of type `TextView` or a subclass of `TextView`.
169
+
170
+
> The following example
171
+
172
+
```kotlin
173
+
// Assume this is your TextView.
174
+
val textView: TextView
175
+
// Patch a single View.
176
+
PanguTextPatcher.patch(textView)
177
+
```
178
+
179
+
::: warning
180
+
181
+
When using `PanguTextPatcher` in recycled layouts such as `RecyclerView`, `ListView`, or `ViewPager`, you need to patch the `itemView` in `onCreateViewHolder` or `onBindViewHolder`,
182
+
otherwise it will not take effect.
183
+
184
+
:::
185
+
153
186
#### Manual Injection or Text Formatting
154
187
155
188
`PanguText`also supports manual injection, allowing you to inject it into the desired `TextView` or `EditText`.
@@ -356,6 +389,7 @@ Don't forget to add the declaration `xmlns:app="http://schemas.android.com/apk/r
356
389
:::
357
390
358
391
In custom `View`, you can extend your `View` to implement the `PanguTextView` interface to achieve the same functionality.
392
+
This feature is also effective for the [Using the Patching Tool](#using-the-patching-tool) method.
0 commit comments