我一直遇到一个对我来说非常奇怪的问题。由于我无法理解的原因,我使用的图形有时会居中,但仅在某些显示器上。上图是一个坏例子,下图是我想要的。它似乎与 Android 版本无关,好的和坏的都在 Android 1.6 上复制,而坏的在 2.1 上复制。它似乎只取决于大小......
相关的 XML 代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<com.google.ads.AdView android:id="@+id/adView"
ads:loadAdOnCreate="true" ads:adSize="BANNER"
ads:adUnitId="@string/admob_unit_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" ></com.google.ads.AdView>
<pearsonartphoto.AJEG.number_pad android:id="@+id/numberpad"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_above="@id/adView"
android:layout_centerHorizontal="true"></pearsonartphoto.AJEG.number_pad>
<pearsonartphoto.AJEG.Level_Score_bar android:id="@+id/Score_Bar"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></pearsonartphoto.AJEG.Level_Score_bar>
<ImageView android:id="@+id/logo_image"
android:layout_below="@id/Score_Bar"
android:layout_above="@id/numberpad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/level_logo"
android:layout_alignParentLeft="true"
android:layout_centerInParent="false"
android:gravity="left"></ImageView>
<TextView android:id="@+id/number_select"
android:layout_above="@id/numberpad"
android:layout_below="@id/Score_Bar"
android:text="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/numberSelect"
android:layout_centerHorizontal="true"
android:gravity="center"></TextView>
<pearsonartphoto.AJEG.number_viewer android:id="@+id/numberviewer"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/Score_Bar"></pearsonartphoto.AJEG.number_viewer>
</RelativeLayout>
如您所见,我已经清楚地将图像的重力设置为左,告诉它与父左对齐,但由于某些未知原因它想要对齐中心。