androidresolution-independence

How to have a button only for large devices on Android?


I know you can have different UI elements by declaring different layout folders like layout-large or layout-xlarge. However, I don't want to have to update two separate files every single time I make a change to my apps interface.

Is there any other way to have a button that only has visibility="gone" on small screens and normal visibility on large screens?


Solution

  • I separated the button into 2 XML files - one in layout-large that has visibility="visible" and one in layout that has visibility="gone", and then include the button in my layout/home.xml file. It worked.