开发者

How to align the image source within the ImageButton?

开发者 https://www.devze.com 2023-03-20 00:22 出处:网络
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

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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号