简体   繁体   中英

Resource size categories (normal / large) - How do i avoid duplication

I have a layout file present for specifically layout-normal-land normal landscape screens, for every other screen size and orientation I want to use the default layout folder -

But, screen sizes higher than normal will now use normal-land as the closest fit resource rather than falling back to default.

I could just add the resource into layout-large-land but this then means (since I want to use this same layout file for portrait screens of all sizes) I would have to make a duplicate copy of the layout file in layout as well.

Can someone tell me how to get around duplicating this file?

I'm hoping this isn't the best case scenario:

Using @PadmaKumar s comment I'm using layout-alias to "override" the id used to load resource in default and large-land instances:

I have this structure instead:

layout/
    fragment_layout_default.xml
layout-normal-land/
    fragment_layout.xml
values/
    layout.xml
values-large-land/
    layout.xml

where as the contents of the layout.xml in values and values-large-land contain:

@layout/fragment_main_menu_default

This stops me from code duplications but still seems a bit... -ick-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM