Fustigador
Fustigador

Reputation: 6459

android:layout_alignBottom not working properly

In my layout, there are an ImageView and a Button (they have botonordenes, and imagelogo as id:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fondo_descripcion_campania"
tools:context=".AlertDetailActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/logotipo_high_density_vinceri_movil" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView1"
    android:src="@drawable/titulo_orden_trabajo_oncheck_high_density_vinceri_movil" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/footer" />

<Button
    android:id="@+id/botonrechaza"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/botonacepta"
    android:layout_alignBottom="@+id/botonacepta"
    android:layout_toRightOf="@+id/botonacepta"
    android:background="@drawable/rechazar_azafata_orden_trabajo_oncheck_high_density_vinceri_movil" />

<Button
    android:id="@+id/botonacepta"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/imageView6"
    android:layout_alignParentLeft="true"
    android:background="@drawable/aceptar_azafata_orden_trabajo_oncheck_high_density_vinceri_movil" />

<Button
    android:id="@+id/botonordenes"
    android:layout_width="wrap_content"
    android:layout_height="30dp"       
    android:layout_toRightOf="@+id/imagelogo"
    android:layout_below="@+id/nombrecampaign"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:background="@drawable/btn_ver_ordenes_trabajo" />

<ImageView
    android:id="@+id/botonalertdetailshome"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/imageView4"
    android:layout_alignParentRight="true"
    android:src="@drawable/home_high_density_vinceri_movil" />

<ImageView
    android:id="@+id/botonalertdetailsos"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/botonrechaza"
    android:layout_alignParentTop="true"
    android:src="@drawable/icono_sos_vinceri_movil_azafatas" />

<TextView
    android:id="@+id/nombrecampaign"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/botonordenes"
    android:layout_below="@+id/imageView4"
    android:text="Nombre Campaña"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#FFFFFF" />

<Button
    android:id="@+id/botonubicaciones"
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_alignBottom="@+id/imageView2"
    android:layout_alignLeft="@+id/botonordenes"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:background="@drawable/btn_ver_ubicaciones_campania" />



<TextView
    android:id="@+id/textdescenc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="14dp"
    android:layout_toRightOf="@+id/imageView5"
    android:layout_alignBottom="@+id/imageView5"
    android:text="@string/desc"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginRight="15dp"
    android:layout_toLeftOf="@+id/textofechainicioenc"
    android:src="@drawable/icono_calendario" />

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageView3"
    android:layout_below="@+id/imageView3"
    android:layout_marginTop="14dp"
    android:src="@drawable/icono_descripcion" />

<TextView
    android:id="@+id/textdetailfechainicio"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView3"
    android:layout_toRightOf="@+id/textofechainicioenc"
    android:text="Small Text"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:layout_above="@+id/botonrechaza"
    android:layout_alignLeft="@+id/imageView3"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/textdescenc"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textdescdetail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>

<TextView
    android:id="@+id/textofechainicioenc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView3"
    android:layout_alignRight="@+id/imageView1"
    android:layout_marginRight="15dp"
    android:text="@string/fechainicio"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="70dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imagelogo"
    android:layout_marginTop="10dp"
    android:src="@drawable/icono_mapa_ubicacion" />

<ImageView
    android:id="@+id/imagelogo"
    android:layout_width="69dp"
    android:layout_height="65dp"
    android:layout_alignBottom="@+id/botonordenes"
    android:layout_alignRight="@+id/imageView2" />

As you can see, the image has android:layout_alignBottom="@+id/botonordenes". The problem is, the alignbottom is not working properly. In the emulator it is seen ok, but not in my device. The bottom line of the image is not aligned with the bottom line of the Button. The difference is not a lot, but it is visible. Why are not aligned? I tried to set a margin hoping it would push the image a bit to be aligned, but dont works. Anybody knows why this happens, and how to solve it? Thank you.

Upvotes: 2

Views: 5970

Answers (2)

TronicZomB
TronicZomB

Reputation: 8747

It either has to do with the predefined margins on Buttons or your hardcoded height and width values on the ImageView

Upvotes: 1

snowCrabs
snowCrabs

Reputation: 785

What you are probably seeing is the difference between default android and what is implemented on your device for the image used on the default button. Try using one of the Holo themes and see if you still have the same issue.

Upvotes: 1

Related Questions