Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align the image source within the ImageButton?

I have an image button that I want to take to entire width of the device. The image src I am using is not as long as the button. The default seems to be to align it to the cener of the button. Instead I would like to align it to the left. I have tried using layout gravity but with no response.

Here is the code..

<LinearLayout 
   android:id = "@+id/llRoot"
   android:orientation="vertical"
   android:layout_width="fill_parent" 
   android:layout_height="fill_parent"
   android:layout_gravity="left"  >

    <ImageButton 
    android:id="@+id/ibSend"
    android:layout_gravity="left"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:src="@drawable/send" >
     </ImageButton>

like image 725
Mel Avatar asked Jul 14 '11 03:07

Mel


1 Answers

Well, I think you want your image in ImageButton to be alligned to the Left? Then add this to your ImageButton attributes:

android:scaleType="fitStart"

and here it goes, your image is aligned at left of the ImageButton.

like image 63
Khawar Avatar answered Sep 22 '22 09:09

Khawar