I would like to show an Activity (use AppCompat) as Dialog when my device is a tablet.
Here is my theme for MyAppCompatActivity
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowNoTitle">true</item>
</style>
When I put directly this theme in my Manifest.xml like this, works fine :
<activity android:name=".MyAppCompatActivity" android:theme="@style/AppDialogTheme"/>
But when I would like set my theme programmatically, my Activity appears as dialog but the background overlay is black (and not transparent as the first method). Here is my code :
public abstract class MyAppCompatActivity extends AppCompatActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
if(isTablet)
{
setTheme(R.style.AppDialogTheme);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
}
}