I need to center an ImageView and TextView inside a RelativeLayout.
I can’t figure out what I’m 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’ve tried the “center_horizontal” with no success.
I need the ImageView will be to the right of the TextView.
=> Try
android:layout_centerInParent="true"for your TextView, and useandroid:layout_toRightOf="@+id/teamNamein your ImageView.