public class ActivityAppSettings extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { if (getApplication() != null && ((ApplicationBase) getApplication()).mTheme > 0) { setTheme( ((ApplicationBase) getApplication()).mTheme ); } super.onCreate(savedInstanceState); if (getResources().getString(R.string.config_screen_type).equals("xlarge")) { requestWindowFeature(Window.FEATURE_NO_TITLE); Rect display = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(display); getWindow().setBackgroundDrawable(new ColorDrawable(0)); getWindow().setLayout( (int) ((display.width() > display.height() ? display.height() : display.width()) * 0.7), (int) (display.height() * 0.7) ); } setContentView(R.layout.activity_app_settings); } }
Sure enough it worked, but with one little issue. The space around the Activity was not transparent. It seamed that you could not change the window background from within the Activity. The panel however was removed, the size was set at 70% of the screen size and my custom theme had been applied to the content within, but with a black background surrounding it all.
I needed another work-around. I went to AndroidManifest.xml and applied Androids's Translucent theme to the Activity.
<activity android:theme="@android:style/Theme.Translucent"
The Activity theme would still be replaced by my Custom theme from within the Activity, but since you cannot change the window background from within there, the transparency would still stick. And then on Phones, you just apply a background to the main View, which you then configure as match_parent for both height and width, which will overlay the transparent window background, making it seam like a regular full-screen Activity.
No comments:
Post a Comment