Top

Documentation Index

Fetch the complete documentation index at: https://support.whatfix.com/llms.txt

Use this file to discover all available pages before exploring further.

Tag Android Views

Prev Next

Why should you tag Android views?

The Whatfix Mobile SDK uniquely identifies the screen of native apps with the properties of a UI element like resource-id, tag, content-description, and more on the screen. Adding any of these properties helps in identifying the element and hence the app screen more accurately.

How to add a resource-id to any view?

A resource-id is a unique identifier for any view. It can be added via XML.


<Button
        android:id="@+id/btn_ok"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ok">
</Button>


How to add a tag to a view?

Tags are extra information associated with a view. A tag can be added in two ways:

  • Using Java
  • Using XML

Using Java

button.setTag("tag_btn_ok");

Using XML

<Button
        android:tag="tag_btn_ok"
        android:id="@+id/btn_ok"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ok">
</Button>

How to add content-description to a view?

The content-description describes the purpose of a particular view.

Info

For more information on content-description, see Describe each UI element.

The content-description attribute can be added in two ways:

  • Using Java
  • Using XML

Using Java

imageView.setContentDescription("Arrow Icon");

Using XML

<ImageView
        android:contentDescription="Arrow Icon"
        android:tag="tag_img_arrow_icon"
        android:id="@+id/img_arrow_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/arrow_icon">
</ImageView>
Privacy Policy | Whatfix Glossary | Whatfix Platform Status
Copyright © 2024 WHATFIX TM. All rights reserved.