Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between android:layout_alignRight="ID" and android:layout_toRightOf="ID"?

What is the difference between android:layout_alignRight="@id/someId" and android:layout_toRightOf="@id/someId"?

like image 445
Giorgi Tsiklauri Avatar asked Jul 24 '15 07:07

Giorgi Tsiklauri


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.

What is Android RelativeLayout?

RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).

Why do we use relative layout?

Android RelativeLayout enables you to specify how child views are positioned relative to each other. The position of each view can be specified as relative to sibling elements or relative to the parent.


2 Answers

This picture will explain the difference :

enter image description here

like image 156
Skynet Avatar answered Nov 03 '22 18:11

Skynet


layout_alignRight aligns the right edges of the two views.

layout_toRightOf aligns the left edge of this view with the right edge of the other someId view.

Documentation: http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html

like image 40
laalto Avatar answered Nov 03 '22 19:11

laalto