I have two questions:
I have an imageview that when I touch it I send it to an (X,Y) position. I have an S4 and a Galaxy Note 3 both with resolution (1920x1080) and density xxhdpi. When i test them, i notice the imageView in different devices not send to same position. In Galaxy note the imageView is more to the right and above... why is this happening? have the same resolution and belongs to same density (xxhdpi)! And how can i fix this for this example and all the screens?
Here is my XML code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/fondo_jugar"
tools:context="com.trucouruguayo.JugarActivity" >
<ImageView
android:id="@+id/imageViewCard1"
android:layout_width="101dp"
android:layout_height="142.50dp"
android:layout_alignLeft="@+id/imageViewMazo"
android:layout_alignTop="@+id/imageViewMazo"
android:layout_marginRight="-50dp"
android:contentDescription="@string/imageViewDescriptionCartd1"
android:src="@drawable/reverso"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/imageViewCard2"
android:layout_width="101dp"
android:layout_height="142.50dp"
android:layout_alignLeft="@+id/imageViewMazo"
android:layout_alignTop="@+id/imageViewMazo"
android:layout_marginRight="-50dp"
android:contentDescription="@string/imageViewDescriptionCard2"
android:src="@drawable/reverso"
android:tag="imageViewCarta1"
android:scaleType="fitXY" />
...
</<RelativeLayout >
And this is the method that move the card:
Point point1 = new Point(-1460, 20);
/*Tira la carta al a mesa (sea de la maquina o del jugador)*/
private void tirarCartaALaMesa(View view, List<Carta> cartas, boolean tiraMaquina) {
cartas.remove(obtenerCartaFromView(view, cartas));
listaImageViewsTiradas.add(view);
indiceOrdenCartas ++;
animSetXY = new AnimatorSet();
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 0.8f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 0.8f);
ObjectAnimator rotation;
objectX = ObjectAnimator.ofFloat(view, "translationX", point1.x);
objectY = ObjectAnimator.ofFloat(view, "translationY", point1.y);
animSetXY.setInterpolator(new LinearInterpolator());
animSetXY.setDuration(500);
animSetXY.start();
}
Another question I realized is why point1 have to set (-1460, 20) to be in the top left corner and not for example (20,20). I think is because it tooks the (0,0) from the views position. Its a posibility to change that?
Greets