IViewTranslationCallback.OnShowTranslation(View) 方法

定義

當翻譯的文字準備好顯示,或使用者要求在隱藏后重新顯示翻譯的內容時呼叫。

[Android.Runtime.Register("onShowTranslation", "(Landroid/view/View;)Z", "GetOnShowTranslation_Landroid_view_View_Handler:Android.Views.Translation.IViewTranslationCallbackInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=31)]
public bool OnShowTranslation (Android.Views.View view);
[<Android.Runtime.Register("onShowTranslation", "(Landroid/view/View;)Z", "GetOnShowTranslation_Landroid_view_View_Handler:Android.Views.Translation.IViewTranslationCallbackInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=31)>]
abstract member OnShowTranslation : Android.Views.View -> bool

參數

view
View

傳回

true 如果檢視句柄顯示翻譯,則為 。

屬性

備註

當翻譯的文字準備好顯示,或使用者要求在隱藏后重新顯示翻譯的內容時呼叫。

翻譯的內容可以從取得 View#getViewTranslationResponse。 在 或 View#onVirtualViewTranslationResponses之前View#onViewTranslationResponse,將不會呼叫這個方法。

注意:使用者可能會變更導致新傳回顯示新 ViewTranslationResponse 翻譯的文字。 如果您快取 ViewTranslationResponse 這裡,您應該記得將快取的值保持在最新狀態。

注意:若為 TextView 實作, ContentCaptureSession#notifyViewTextChanged 不應該使用翻譯的文字呼叫,只要在這裡呼叫 setText() 就會觸發 方法。 您應該覆寫 View#onProvideContentCaptureStructure() 以報告原始文字,而不是翻譯的文字,或使用不同的方法來顯示翻譯的文字。

注意:在 Android 版本和更新版本中 android.os.Build.VERSION_CODES#TIRAMISU ,實作必須能夠處理可 android.widget.TextView 選取的 (亦即 傳 android.widget.TextView#isTextSelectable()true。 TextView 的預設回呼實作會使用 android.text.method.TransformationMethod 來顯示翻譯的文字,這會在選取翻譯的文字時造成當機。 因此,預設回呼會在顯示翻譯文字時暫時讓 TextView 無法選取。 這是用來處理可選取的 TextViews TransformationMethod 的方法之一。

如需如何取得翻譯的資訊,請參閱 View#onViewTranslationResponse

android.view.translation.ViewTranslationCallback.onShowTranslation(android.view.View)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於