Android Studio 3.1 layout preview does not show preview for some layouts

前端 未结 4 593
情深已故
情深已故 2020-12-20 14:30

Since today morning I started encountering this weird issue. Android Studio layout preview panel and Design view was not displaying some of my layouts which were perfectly f

4条回答
  •  悲&欢浪女
    2020-12-20 15:02

    After many failed attempts and submitting it to Android Studio bug tracker and giving it an another try. I found that it was due to a missing "+".

    Sample layout to demonstrate the issue

    
    
    
        
    
        
    
    
    

    The issue was because of a missing + in leftTextView id declaration. After changing the line (line no. 18)

    android:id="@id/leftTextView"

    to

    android:id="@+id/leftTextView"

    Android Studio layout preview panel started displaying the layout.

    Note : I always used to declare view ids (i.e., "@+id") only once in a layout file at its first occurrence(either declaration or reference) and there was no issue with layout preview or running the App till now

提交回复
热议问题