0

i have image-view in my xml for setting the image over a background image at a specified place of back ground image i set it for one emulator and it works but when i launch other emulator of different size image-view change it corresponding position with respect to background image so how to set image view over a background image so that imageview not changes its position for any size of screen i am providing my code ...thanks in advance..

here is my splash.xml file ,button and imageview changes its position w.r.t. background image..for diffrent size screen emulator

<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>
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
saurabh trivedi
  • 31
  • 1
  • 1
  • 2

2 Answers2

0

Did not understand the question, you might consider uploading some images and giving us links to them. Only thing I can tell is that you must avoid using px when indicating any dimensions. This will make your views look different on every device, that you probably don't want.

Egor
  • 39,695
  • 10
  • 113
  • 130
  • then what should i use in plase of px??if i use sp in place of px then also problem is not solved.. – saurabh trivedi Jun 14 '11 at 06:47
  • @saurabh, you should use `dp` (density-independent pixels) instead of `px` : http://stackoverflow.com/questions/2025282/difference-of-px-dp-dip-and-sp-in-android – Andrei Sfat Jun 14 '11 at 06:50
  • You can use dp, sp or dip. You may take a look at this post to make it absolutely clear: http://developer.android.com/guide/topics/resources/more-resources.html#Dimension – Egor Jun 14 '11 at 06:50
  • @Andrei Sfat no difference takes place when using dp,sp or dip in the layout view – saurabh trivedi Jun 14 '11 at 06:56
  • Check the the link I've posted above – Egor Jun 14 '11 at 07:15
0

use dip instead of px and sp.

Your xml will be

<?xml version="1.0" encoding="utf-8"?>
<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="60dip" 
        android:layout_height="60dip" 
        android:id="@+id/SplashImageView"

        android:layout_marginTop="120dip"
        android:layout_marginLeft="55dip"
        android:background="@drawable/a_thumb"
        />


    <Button 
         android:text="SUBMIT" 
         android:id="@+id/submitt"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" 
         android:layout_marginLeft="75dip"
         android:layout_marginTop="300dip"
        />
</RelativeLayout>

Thanks Deepak

Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243