My app contains only one activity and I want it to be opened as a small sized activity on top of the current active activity.
For example, if the app has a shortcut on the desktop and the user activates it then the main activity will open on top of the main desktop view in a small size (deviceHight / 2, deviceWidth / 2) box. If the app clicked from the app drawer the the drawer view will be visible behind the app activity.
Kind of a popup but with no parent activity.
Do you mean like a Dialog? Apply a custom theme to your activity will do the trick. Android have already defined a style which will make our Activity looks like a Dialog:
@android:style/Theme.Dialog.There are two ways to apply theme to your activity:
1, Set
android:themeattribute to the activity in AndroidManifest.xmlThis is the easiest way to apply custom theme, following is an example:
2, Using
Activity.setThememethodYou should pass a style resource id to this method, in your case, you can use
android.R.style.Theme_Dialog. Note that you should call this method before you callsetContentViewso that the theme will be applied to the content view.