Android: cómo colocar exactamente una imagen dentro de un botón normal

Im trying to place an icon thats 16x16 pix within a normal button that I have in a layout. This button also uses another png for its background. The problem I have is not placing it within the button but placing it where I want. When I add it using the following code it places the drawable at the bottom but exactly on the edge of the image which looks terrible.

 <Button
    android:id="@+id/clearform"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/helpText"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="19dp"
    android:typeface="monospace"
    android:textColor="#FFFF00"
    android:drawableBottom="@drawable/cross"

What I would like is to create a button in my layout that possibly has some padding from the bottom but there is no such method or xml attribute that does such a thing the way I would like. Its only left right top or bottom and when I added padding it only placed padding between the bottom of the text in the button and the top of the drawable.

So how can I accurately place an image within the button itself.

preguntado el 10 de marzo de 12 a las 01:03

I think you can adjust the paddings for the image with android:padding, android:paddingBottom and its like. -

As far as i can see you can only add padding which places the drawable to far to the edge of the button -

1 Respuestas

I think you can use android:padding for aligning to a greater extent & use android:paddingTop/Right/Left/Bottom to get the exact postion.It would be much easier.

respondido 10 mar '12, 07:03

That did the trick.....I just added paddingBottom="10dip" and it put it right where I wanted. Now hopefully in some testing on hardware it ends up in the same place - james andresakis

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.