I want a TextView
on top and a VideoView
below it. I want to have the VideoView
as center verical and below the TextView
. I am using RelativeLayout
.
I am trying to do this in code:
RelativeLayout layout = new RelativeLayout(this);
TextView tv = new TextView(this);
tv.setText("Hello");
tv.setGravity(Gravity.RIGHT);
tv.setTextColor(Color.WHITE);
tv.setId(1);
RelativeLayout.LayoutParams one = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
one.addRule(RelativeLayout.ALIGN_PARENT_TOP);
one.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
RelativeLayout.LayoutParams two = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
two.addRule(RelativeLayout.CENTER_VERTICAL);
two.addRule(RelativeLayout.BELOW, 1);
VideoView mVideoView = new VideoView(this);
layout.addView(tv, one);
layout.addView(mVideoView, two);
setContentView(layout);
The VideoView
gets placed below the TextView
, but the VideoView
is not center vertical.