Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - What is the use of attributes having the wrench icon?

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!!!

like image 559
Stack Overflow Avatar asked Mar 04 '23 15:03

Stack Overflow


2 Answers

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.

like image 169
CommonsWare Avatar answered Mar 06 '23 03:03

CommonsWare


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

like image 38
a_local_nobody Avatar answered Mar 06 '23 04:03

a_local_nobody