You can separate it into two XML layout files but then you have to maintain both. You can abstract it out by having one layout file and then give the button a style that's defined for both tablets and not.
I would set it to GONE and change it in code. That way you don't have two layout files.
However, I would not use Blumer's method of getConfiguration().screenLayout
. Buckets are no longer the best way to handle different screen sizes. Dianne Hackborn explains why in a post, but it boils down to:
Based on developers’ experience so far, we’re not convinced that this
limited set of screen-size buckets gives developers everything they
need in adapting to the increasing variety of Android-device shapes
and sizes. The primary problem is that the borders between the buckets
may not always correspond to either devices available to consumers or
to the particular needs of apps.
Instead, you should use their new numeric values--roughly sw600dp
for 7" tablets and sw720dp
for 10":
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mylayout);
if (getResources().getBoolean(R.bool.sw600dp)) {
((Buton)findViewById(R.id.mybutton)).setVisibility(VISIBLE);
}
}