mercredi 6 mai 2015

Placing ImageButtons correctly on top of an ImageView inside a RelativeLayout

I'm trying to develop my first real Android App that goes beyond "Hello World". For a few days now though, I am stuck on a problem and all the googling and asking around I did, did not bring me to a solution that worked yet.

I am trying to put a few ImageButtons on top of an ImageView in my RelativeLayout. Now my problem is, that no matter how I try to align my Buttons, they change their position relative to my ImageView as soon as I change my device, or rather the resolution.

This is where I am at so far with the Layout:

    <RelativeLayout
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    tools:context="de.paddex.csgolearntosmoke.dust2OverviewActivity">

   <ImageView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:id="@+id/dust2OverView"
       android:src="@drawable/de_dust2_radar"
       android:layout_alignParentTop="true"
       android:layout_alignParentRight="true"
       android:layout_alignParentEnd="true" />

   <ImageButton
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:id="@+id/imageButton"
       android:background = "@null"
       android:src="@drawable/smokeicon2"
       android:layout_alignTop="@id/dust2OverView"
       android:layout_alignRight="@id/dust2OverView"
       android:layout_marginRight="55dp"
       android:layout_marginTop="140dp" />
</RelativeLayout>

And this is what the difference looks like between my Android Studio and my Android device: http://ift.tt/1Re1kKb

On the left is what it's supposed to look like and how I aligned it in my AndroidStudio and on the right is the result my device produces.

I am kinda lost and appreciate every answer that might help me solve this problem.

Aucun commentaire:

Enregistrer un commentaire