I created an non-maximized activity using android:theme="@android:style/Theme.Dialog" to make it looks like a dialog. I need to change the position of the activity on screen but I didn't find how to do this...
I created an non-maximized activity using android:theme="@android:style/Theme.Dialog" to make it looks like a dialog. I need to change the position of the activity on screen but I didn't find how to do this...
Create a custom theme with Theme.Dialog as its parent:
<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
So, for each item in the Dialog theme that you want to change, use CustomDialogTheme instead of Theme.Dialog inside the Android Manifest. See the android developper docs for details.
For bottom:
Keep this in your activity.
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
try {
View view = getWindow().getDecorView();
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) view.getLayoutParams();
layoutParams.gravity = Gravity.BOTTOM;
getWindowManager().updateViewLayout(view, layoutParams);
} catch (Exception e) {
e.printStackTrace();
}
}
Note: You can change your gravity by setting this Gravity.BOTTOM (TOP, LEFT, RIGHT)