65

i just came to know that we can set the text by using tools:text="toolsText". before this i was using android:text="androidText".

Please tell me 1.what are differences between these two feature 2.which one is best to use 3.What are there effect during ui rendering

Suraj Bahadur
  • 3,730
  • 3
  • 27
  • 55

1 Answers1

138
  1. tools:text="toolsText" is used only for Android Studio layout preview, it doesn't show text when you run an app. It's perfect, when you don't want to set a text until you do some calculations, and only then set text programmatically by yourself in activity, also you want to see preview layout when you write code in Android Studio, how it will look like when you run an app.
  2. android:text="androidText" is used to set text to a layout element, textView or a button etc.
miljon
  • 2,611
  • 1
  • 16
  • 19
  • 6
    That's not quite right. You define what the namespaces are in the first tag of your resource file. Generally, tools is set to be the android studio preview, but it doesn't have to be. Same for android. You will occassionally see something that doesn't follow normal conventions. – Gabe Sechan Mar 24 '17 at 14:42
  • 5
    **tools:text** -> is used just for layout preview. For example if you want to test you textView with different text while development, you can use it for your android studio preveiw. **android:text** -> is the text to be displayed. You can add both the android: namespace attribute (which is used at runtime) and the matching tools: attribute (which overrides the runtime attribute in the layout preview only) – Zia Mar 24 '17 at 15:09