Center inside RelativeLayout

I need to center ImageView and TextView inside RelativeLayout. I cannot understand what I am doing wrong.

Here is my code:

<RelativeLayout android:id="@+id/teamNameLayout" android:layout_width="130dip" android:layout_height="fill_parent" android:orientation="horizontal" android:background="@drawable/border" android:layout_toLeftOf="@+id/teamPosition" > <ImageView android:id="@+id/teamIcon" android:src="@drawable/logo1" android:layout_width="20dip" android:layout_height="fill_parent" android:scaleType="fitXY" android:textStyle="bold" android:textSize="16sp" /> <TextView android:id="@+id/teamName" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:textColor="#000000" android:textStyle="bold" android:textSize="16sp" android:text="blabla" /> </RelativeLayout> 

I tried "center_horizontal" without success. I need the ImageView to be to the right of the TextView.

+4
source share
1 answer

I tried "center_horizontal" without success. I need an ImageView to the right of the TextView.

=> Try android:layout_centerInParent="true" for your TextView and use android:layout_toRightOf="@+id/teamName in your ImageView.

+9
source

All Articles