This answer is based off the explanation provided here by Flávio Faria.
The visible
, gone
, etc can be values mapped to their corresponding enum values in a string resource - which means you can create a visibilty.xml
with string resources for each layout you want, and Android will automatically resolve the one you want for each screen type.
I'd recommend the following:
/res/values/visibilty.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Enum values pulled from Android source -->
<string name="visibility_visible">0</string>
<string name="visibility_invisible">1</string>
<string name="visibility_gone">2</string>
<string name="product_info_footer_button_visibility">@string/visibility_visible</string>
</resources>
/res/values-large/visibilty.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="product_info_footer_button_visibility">@string/visibility_invisible</string>
</resources>
And then you can reference the visibility as follows for your button:
<Button
android:id="@+id/btn_check_availability"
style="@style/product_info_footer_button"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:text="@string/check_availability"
android:visibility="@string/product_info_footer_button_visibility" />
Warning: This depends on the device having the same enum values for visibility (0/1/2) as defined in the AOSP source. Device manufacturers and custom ROM creators can change these values, in which case this code will likely not work as desired.