How to add an include layout in coordinator layout in Android Studio?

0 votes
asked by about Android Studio
edited by

I created two XML activities. One is for the activity interface layout and another one is the for the coordinator layout. I added the included layout for the interface layout activity into the coordinator layout and I can't see my interface layout from the preview. The preview is blank and these are the errors it's showing me:


Error 1: RENDER PROBLEMS
<item> tag requires a 'drawable' attribute or child tag defining a drawable
___________________________________________________________________________
Error 2: can't make a decor toolbar out of relative layout

java.lang.IllegalStateException: Can't make a decor toolbar out of RelativeLayout
at android.support.v7.widget.ActionBarOverlayLayout.getDecorToolbar(ActionBarOverlayLayout.java:549)
at android.support.v7.widget.ActionBarOverlayLayout.pullChildren(ActionBarOverlayLayout.java:538)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure_Original(ActionBarOverlayLayout.java:339)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java)
at android.view.View.measure_Original(View.java:22071)
at android.view.View_Delegate.measure(View_Delegate.java:80)
at android.view.View.measure(View.java:22035)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure_Original(View.java:22071)
at android.view.View_Delegate.measure(View_Delegate.java:80)
at android.view.View.measure(View.java:22035)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:590)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:343)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

2 Answers

0 votes
No avatar answered by (329k points)

The Mastering Coordinator Layout lessons provided on the GitHub explains exactly what needs to be done in order to make it work. I recommend checking the following URL to access the lessons.

Also, the developers of Android Studio have set up a page with the exact instructions and information on how to proceed with the development part.

0 votes
No avatar answered by (140 points)

you have not use the correct layouts styles.
you have not import necessary libraries for used your layouts.
without choosing a right layout you can not view the preview of your application.
first you import Design, Viewcart, Compilers or implimentations libraries from gradle (app) file.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...