4

I have seen many attributes like text, targetApi etc in Design mode of Android Studio that has the following icon on the left side:

enter image description here

Some of them are more than once for example one text attribute without wrench icon and one with wrench icon. What is the purpose and use? Any examples would be appreciated. Thanks!!!

Stack Overflow
  • 1
  • 5
  • 23
  • 51

2 Answers2

5

The one with the wrench icon controls the tools: attribute, whereas the one without the wrench controls an android: or app: attribute. Attributes in the tools: namespace are only used by development tools and have no runtime effects. So, tools:text says "show this text in this widget in the IDE", while android:text says "show this text in this widget on the device". This is particularly useful in cases where you cannot provide android:text, as the text is not knowable until the app runs — tools:text lets you provide sample text to help with setting up the UI design.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I appreciate your answers sir. Your answer in turns make me compulsory to understand this (https://stackoverflow.com/questions/57271141/android-when-and-for-which-purpose-we-use-the-following-prefixes-in-android-xm) concept, which in turn help me to understand your answer above. I will glade if you help me out. Actually, I am new to android development. – Stack Overflow Jul 31 '19 at 13:15
2

that icon is for the tools namespace. it means that these changes only apply while you are designing your UI in the IDE and will not apply at runtime.

as CommonsWare has said, it's very useful for adding text to components. It's also very useful when designing layouts with several different components which could be hidden or visible

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
  • Sir thanks a lot for great answer, now it is necessary for me understand this (https://stackoverflow.com/questions/57271141/android-when-and-for-which-purpose-we-use-the-following-prefixes-in-android-xm) concept which in turn let me understand the answers of this question. I will glad if you help. Actually, I am new to android development. – Stack Overflow Jul 31 '19 at 13:17