我需要实现固定的中心对齐,如图所示:
http://postimage.org/image/t735us1z3/
因此,标志图像始终位于中心,而两个 TextView 向左和向右增长。因此,无论文本有多长,图像仍将位于中心。再加上中间的“vs”TextView。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
>
<TextView android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
/>
<ImageView
android:id="@+id/flag1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="@drawable/bayern25"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/list_item_entry_title"
/>
<TextView android:text="-"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_toRightOf="@+id/flag1"
/>
<ImageView
android:id="@+id/flag2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:src="@drawable/wolfsburg25"
android:layout_toRightOf="@+id/text"
/>
<TextView android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/list_item_entry_title"
android:layout_alignLeft="@id/list_item_entry_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_toRightOf="@+id/flag2"
/>