How to align a view in RelativeLayout in the upper right corner

Im trying to figure out how to align the view in a relative layout in the upper right corner. It is currently aligned in the upper left corner.

A simple problem, but I do not know how to do this.

Here is the code:

RelativeLayout.LayoutParams gpsViewLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT ); gpsViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); gpsViewLayoutParams.addRule(RelativeLayout.ALIGN_RIGHT); this.relativeLayout.addView(gpsView,gpsViewLayoutParams); 
+6
source share
2 answers

gpsViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); use this instead of gpsViewLayoutParams.addRule(RelativeLayout.ALIGN_RIGHT) ; you can get that way

+11
source

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


All Articles