How to specify id when uses include in layout xml file

前端 未结 11 2557
挽巷
挽巷 2020-12-02 08:55

In my layout xml file, I have included other layout xml file (each with a different android id).



        
11条回答
  •  攒了一身酷
    2020-12-02 09:38

    I think the top answer misses the most important point and might mislead people into thinking the tag creates a View that holds the include contents.

    The key point is that include's id is passed to the root view of the include's layout file.

    Meaning that this:

    // activity_main.xml
    
    
    // somelayout.xml
    
    
    

    Becomes this:

    // activity_main.xml
    
    

提交回复
热议问题