Search code examples
androidandroid-layoutandroid-screen

Which one layout is adding - Android?


I created two resource layout(layout , layout-large) .

How can I find in my code(programmatically) that which one layout is adding ?


Solution

  • As you created two resource folder, one solution is to create these folder for values too. Then for values folder add this:

    <resources>
        <bool name="isLarge">false</bool>
    </resources>
    

    and in your values-large folder:

    <resources>
        <bool name="isLarge">true</bool>
    </resources>
    

    Then in your activity:

    boolean isLarge = getResources().getBoolean(R.bool.isLarge);
    if (isLarge) {
        // do something
    } else {
        // do something else
    }