Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:layout_alignParentBottom by code

How to set android:layout_alignParentBottom="true" for a videoview, by code and not from xml?

like image 545
Gabrielle Avatar asked Dec 06 '11 08:12

Gabrielle


People also ask

What is Layout_above android?

android:layout_above : Places the element above the specified element. android:layout_below : Places the element below the specified element. android:layout_toLeftOf : Places the element to the left of the specified element. android:layout_toRightOf : Places the element to the right of the specified element.

How do you set gravity in RelativeLayout?

There are two main ways to programmatically set the gravity in a RelativeLayout . You can either set the gravity for all child views ( setGravity(int) ) or set the gravity individually ( params. addRule(int) ). Note: These methods are not available for LinearLayout s.

How do you center a button in RelativeLayout?

If you have a single Button in your Activity and you want to center it the simplest way is to use a RelativeLayout and set the android:layout_centerInParent=”true” property on the Button.

Which attribute or property is specific for RelativeLayout?

Some of the many layout properties available to views in a RelativeLayout include: android:layout_alignParentTop. If "true" , makes the top edge of this view match the top edge of the parent. android:layout_centerVertical.


1 Answers

I assume you are trying to add your VideoView to a RelativeLayout ?

RelativeLayout relativeLayout = findViewById(R.id.your_relative_layout);
mVideo = new VideoView(this); 
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // or wrap_content
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
relativeLayout.addView(mVideo , layoutParams);
like image 161
Reno Avatar answered Sep 27 '22 20:09

Reno