Android - RelativeLayout CENTER_VERTICAL and BELOW issue

I want TextViewabove and VideoViewbelow. I want the VideoViewcenter to be true and lower TextView. I use 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);

VideoViewIt is placed below TextView, but is VideoViewnot central vertically.

+3
source share
1 answer

VideoView fill_parent/fill_parent, , RelativeLayout. , RelativeLayout, . , VideoView TextView, ; . ViewView TextView.

+1

Source: https://habr.com/ru/post/1756387/


All Articles