When I run my android application I am calling a method to check if the app is being run on a tablet using:
public boolean isTablet(Context context){
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)== Configuration.SCREENLAYOUT_SIZE_MASK);
return(xlarge || large);
}
if the method returns true(i.e. the device satisfies one of these conditions)
I set my theme to a Dialog theme via:
setTheme(R.style.MyTheme);
where MyTheme
is a theme that inherits from the parent Theme.Holo.Light.Dialog
This logic works fine however it gives me a weird effect in the background. The Calling intent is completely blacked out, whereas if i just set the theme in the manifest the background is only slightly greyed out.
Update - code added
private Context mClassContext = this;
@Override
public void onCreate(Bundle savedInstanceState){
if(isTablet(mClassContext)){
setTheme(R.style.MyTheme);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);
}
How do I replicate this?