Skip to main content
7 of 10
deleted 50 characters in body
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253

tools namespace enables design-time features (such as which layout to show in a fragment) or compile-time behaviors (such as which shrinking mode to apply to your XML resources) It is really powerful feature that is developing and allows you not compile code every time to see changes

Example with GridLayoutManager

<!-- AndroidX --> <androidx.recyclerview.widget.RecyclerView tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" <!-- support --> <android.support.v7.widget.RecyclerView tools:layoutManager="android.support.v7.widget.GridLayoutManager" <!-- common --> xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:itemCount="5" tools:listitem="@layout/item_video" tools:orientation="horizontal" tools:scrollbars="horizontal" tools:spanCount="2" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualized easily your layout structure using tools:text="@tools:sample/last_names". For example your preview will looks like

enter image description here

yoAlex5
  • 35.2k
  • 10
  • 235
  • 253