4

For my main_activity, the layout preview disappeared after i was debugging.

I have 2 other layouts in this Project, in which i can perfectly see the layout in the preview.

Also the component tree says: nothing to show
There is no rendering error showing up, below is xml

enter image description here

Thanks for your help!

Greetings Michael

4
  • click on refresh button first and check if there is an error in your layout file Mar 2, 2016 at 1:55
  • already tried that, but there is no error.. i changed nothing in the xml code..
    – Michael
    Mar 2, 2016 at 2:03
  • Hi Michael. I experience the same problem occasionally without any reasonable cause. Have you found any solution? Apr 28, 2017 at 20:05
  • In my case, I accidentally used TextureView instad of TextView. After I change them to TextView, all appear in preview.
    – YeeKhin
    May 29, 2017 at 10:00

4 Answers 4

3

Have you tried Rebuilding the project, re-opening Android Studio, Invalidate Caches? That is if you are sure you did nothing and it just disappeared.

If that doesn't work, you could try saving the XML code in a txt file, deleting the xml layout, creating an empty one and pasting back the code.

Update: What if you surround your LinearLayout with a ScrollView and then move the app:layout_behavior="@string/appbar_scrolling_view_behavior" to the ScrollView instead. I think everything should work fine then.

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        your ImageView and TextViews here
    </LinearLayout>
</ScrollView>
1

You may have seen that you cannot see anything in "component tree" and have -nothing to show- in the "properties" section and also there is "android..ComponentLayout" showing in the preview built of the emulator.

I myself had tried different methods, but found the most convenient method to just remove the 3 lines of the code in the Main_Activity.xml file or you can just paste the following code or compare it with this one :

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>

0

I have found the solution. In fact there is a bug in android studio. In my case the problem is that when I enable the tabStripEnabled from "Properties" window, the component tree shows "Nothing to show" and when I disable it, everything goes well again. So I solved this problem by coding programmatically :

tabHost.getTabWidget().setStripEnabled(true);

So I think you should to examine everything one by one in order to find the solution. I hope this could be helpful.

-3

I have encountered this problem, but I am by modifying the configuration in the build.gragle file to solve this problem:

enter image description here

enter image description here

1
  • Please fix "enter image description here" Feb 27, 2017 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.