我在我的xml中有圖像視圖,用於在背景圖像的指定位置設置背景圖像的圖像,我將其設置爲一個模擬器並且它可以工作,但是當我啓動其他不同大小的圖像視圖模擬器改變它相對於背景圖像的相應位置,所以如何在背景圖像上設置圖像視圖,以便imageview不會改變其對於任何大小屏幕的位置 我正在提供我的代碼...在此先感謝..在背景圖像上設置圖像的問題android
這裏是我的splash.xml文件,按鈕和imageview改變其位置wrt背景image..for不同勢尺寸屏幕模擬器
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/TheSplashLayout"
android:layout_gravity="center"
android:background="@drawable/splashmodified"
>
<ImageView
android:layout_width="60sp"
android:layout_height="60sp"
android:id="@+id/SplashImageView"
android:layout_gravity="center"
android:layout_marginTop="120sp"
android:layout_marginLeft="55sp"
/>
<Button
android:text="SUBMIT"
android:id="@+id/submitt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="75px"
android:layout_marginTop="300px"
/>
</RelativeLayout>
那麼我應該在PX的plase使用?如果我在的地方像素的則也問題不解決.. – 2011-06-14 06:47:59
使用SP @ saurabh,你應該使用'dp'(密度獨立像素)而不是'px':http://stackoverflow.com/questions/2025282/difference-of-px-dp-dip-and-sp-in-android – sfat 2011-06-14 06:50:06
您可以使用dp,sp或dip。你可以看看這篇文章,以便說清楚: http://developer.android.com/guide/topics/resources/more-resources.html#Dimension – Egor 2011-06-14 06:50:39