Freigeben über


Fragment.UserVisibleHint Property

Definition

Set a hint to the system about whether this fragment's UI is currently visible to the user.

public virtual bool UserVisibleHint { [Android.Runtime.Register("getUserVisibleHint", "()Z", "GetGetUserVisibleHintHandler")] get; [Android.Runtime.Register("setUserVisibleHint", "(Z)V", "GetSetUserVisibleHint_ZHandler")] set; }
[<get: Android.Runtime.Register("getUserVisibleHint", "()Z", "GetGetUserVisibleHintHandler")>]
[<set: Android.Runtime.Register("setUserVisibleHint", "(Z)V", "GetSetUserVisibleHint_ZHandler")>]
member this.UserVisibleHint : bool with get, set

Property Value

The current value of the user-visible hint on this fragment.

Attributes

Remarks

Property getter documentation:

Java documentation for android.app.Fragment.getUserVisibleHint().

Property setter documentation:

Set a hint to the system about whether this fragment's UI is currently visible to the user. This hint defaults to true and is persistent across fragment instance state save and restore.

An app may set this to false to indicate that the fragment's UI is scrolled out of visibility or is otherwise not directly visible to the user. This may be used by the system to prioritize operations such as fragment lifecycle updates or loader ordering behavior.

<strong>Note:</strong> This method may be called outside of the fragment lifecycle and thus has no ordering guarantees with regard to fragment lifecycle method calls.

<strong>Note:</strong> Prior to Android N there was a platform bug that could cause setUserVisibleHint to bring a fragment up to the started state before its FragmentTransaction had been committed. As some apps relied on this behavior, it is preserved for apps that declare a targetSdkVersion of 23 or lower.

Java documentation for android.app.Fragment.setUserVisibleHint(boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also