Skip to main content
added 69 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253

Android tools and LayoutManager

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

AndroidXAndroidX[About] and GridLayoutManagerGridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

SupportSupport library and LinearLayoutManagerLinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:Simulator results:

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

AndroidX[About] and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:

Android tools and LayoutManager

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

AndroidX[About] and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support library and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Simulator results:

added 78 characters in body
Source Link
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

AndroidX[About] and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:background="#303F9F" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:

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

AndroidX and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:background="#303F9F" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:

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

AndroidX[About] and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:

added 1005 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253

Example withAndroidX and GridLayoutManager

<!-- AndroidXimplementation --> <androidx'androidx.recyclerview.widget.RecyclerView tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" <!-- support --> <android.support.v7.widget.RecyclerView tools:layoutManager="android.support.v71.widget1.GridLayoutManager" <!-- common -->0'  
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation xmlns:android="http://schemas'com.android.com/apk/res/android" xmlnssupport:tools="httprecyclerview-v7://schemas28.android0.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" />0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualizedvisualised easily your layout structure using tools:text="@tools:sample/last_names"@tools:sample/* resources

item. For example your preview will looks likexml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:background="#303F9F" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

enter image description here Results:

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

AndroidX and GridLayoutManager

implementation 'androidx.recyclerview:recyclerview:1.1.0' 
<androidx.recyclerview.widget.RecyclerView 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:layoutManager="androidx.recyclerview.widget.GridLayoutManager" tools:listitem="@layout/item" tools:itemCount="10" tools:orientation="vertical" tools:scrollbars="vertical" tools:spanCount="3"/> 

Support and LinearLayoutManager

implementation 'com.android.support:recyclerview-v7:28.0.0' 
 <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/item" tools:itemCount="3" tools:orientation="horizontal" tools:scrollbars="horizontal" /> 

Another cool feature that was introduced in Android studio 3.0 is predefining a data through the tools attributes, to visualised easily your layout structure using @tools:sample/* resources

item.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="150dp" android:layout_marginRight="15dp" android:layout_marginBottom="10dp" android:background="#303F9F" android:orientation="vertical" tools:background="@tools:sample/backgrounds/scenic"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorWhite" tools:text="@tools:sample/first_names" /> </FrameLayout> 

Results:

deleted 50 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading
added 209 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading
Fixed a link so that it opens correctly
Source Link
frozenkoi
  • 3.2k
  • 24
  • 33
Loading
added 4 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading
added 40 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading
added 252 characters in body
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading
Source Link
yoAlex5
  • 35.2k
  • 10
  • 235
  • 253
Loading