Preview layout with merge root tag in Intellij IDEA/Android Studio

前端 未结 3 1963
小鲜肉
小鲜肉 2021-01-29 21:26

Let\'s imagine we are developing compound component based on LinearLayout. So, we create class like this:

public class SomeView extends LinearLayout {
    public         


        
3条回答
  •  时光取名叫无心
    2021-01-29 21:42

    There is a new parentTag tools attribute (added in Android Studio 2.2) that you can use to specify the layout type for a merge tag, which will make the layout render correctly in the layout editor preview.

    So using your example:

    
    
        
    
        
    
    

    Note: Both android:layout_width and android:layout_height must be specified in order for the layout to display properly in the editor.

提交回复
热议问题