How to get RelativeLayout working with merge and include?

前端 未结 8 1941
余生分开走
余生分开走 2020-12-02 04:37

I have been trying for a few days now to make my layouts more efficient by converting from using several levels of nested LinearLayouts to one RelativeLay

相关标签:
8条回答
  • 2020-12-02 05:41

    In my case, the layout which I was trying to include starts with <merge tag. When I changed it to a layout, say <RelativeLayout it worked. Below is the illustration.

    WORKING

    <RelativeLayout xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android"
        tools:showIn="@layout/activity_home">
    

    NOT WORKING

    <merge xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android"
        tools:showIn="@layout/activity_home">
    
    0 讨论(0)
  • 2020-12-02 05:44

    There is an issue with the include tag. Check: https://issuetracker.google.com/issues/36908001

    To fix it, make sure you overwrite BOTH layout_width and layout_height when including, otherwise everything will be ignored.

    0 讨论(0)
提交回复
热议问题