main build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
...
classpath 'io.fabianterhorst:fastlayout-gradle-plugin:0.0.2-alpha37'
...
}
}
app build.gradle
...
apply plugin: 'fastlayout'
...
This is needed to filter the layouts you want to compile
//this is compiling all layouts in layout folder
@Layouts(all = true, exclude = {R.layout.sample_item})
//there you can specify the layouts
//@Layouts(layouts = {"activity_main", "fragment_one"})
//@Layouts(ids = {R.layout.activity_main, R.layout.fragment_one})
//this is needed when you want to use the class fields
//@Layouts
public class AppLayouts {
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//when you don´t wanna use the cache you can also just initiate the object
//setContentView(new ActivityMainLayout(this));
//The cache is reusing the object to improve the performance
ActivityMainLayout layout = LayoutCache.getInstance().getLayout(context, LayoutCache.Activity_Main_Layout);
setContentView(layout);
}
}