So, I have an activity that is launched as a dialog (Theme.Dialog). I use it to play a video, dimming the background, and looks pretty cool... but it's always centered on the screen and don't know how to move it to the bottom programmatically.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lr_layout"
android:background="#FF000000"
android:padding="0dp" >
<RelativeLayout
android:id="@+id/lr_progressContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF000000">
<ProgressBar android:id="@+id/lr_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/black"
style="@android:style/Widget.ProgressBar.Large" />
<View android:id="@+id/disableShape"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:visibility="gone"
android:background="#CC000000"
/>
</RelativeLayout>
</RelativeLayout>
And then I add the video player programmatically (View from 3rd party).
I've tried this:
layout = (ViewGroup) findViewById(R.id.lr_layout);
layout.setY(0);
and this:
RelativeLayout.LayoutParams adViewLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
adViewLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM);
layout.addView(adView, adViewLayoutParams);
But the video is still in the center.
Any idea?
Thanks!
Try putting this in your onCreate method.
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.gravity = Gravity.BOTTOM;
getWindow().set attributes(lp);