Bug 28469 - [Forms] Button Image does not respect WidthRequest for alignment
Summary: [Forms] Button Image does not respect WidthRequest for alignment
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-26 12:48 UTC by Cody Beyer (MSFT)
Modified: 2015-05-27 17:44 UTC (History)
5 users (show)

Tags: android visual button
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Cody Beyer (MSFT) 2015-03-26 12:48:47 UTC
### Description

When setting the image property for a button within Xamarin.Forms, the button generally aligns just left of the text of the button. However, when a WidthRequest is set, the text centers within the available width, but the image does not

### Test Case

https://www.dropbox.com/s/g3kfljfljqvense/AndroidButtonImageBug.zip?dl=0

### Steps to Reproduce

1. Open linked test case
2. Deploy to Android Simulator
3. Notice that the image is justified to the left and the text is centered
4. Comment out line 22 of AndroidButtonImageBug.cs and uncomment line 24
5. Run again

### Expected Results

The image should be just next to and left of the text on steps 3 and 5

### Actual Results

The image is only next to the text at step 5

### Desired Layout

https://www.dropbox.com/s/ib6zzwn77p9wqvr/Desired.png?dl=0

### Actual Layout

https://www.dropbox.com/s/wlz8yjsk3kbpsw0/Actual.png?dl=0

### Version

=== Xamarin Studio ===

Version 5.8 (build 443)
Installation UUID: 40fcd6d9-7dc3-4278-821c-85b312276a62
Runtime:
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.0.2 (Business Edition)
Hash: ccfcd59
Branch: 
Build date: 2015-03-10 02:20:32-0400

=== Xamarin.Android ===

Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

=== Operating System ===

Mac OS X 10.10.2
Darwin Codys-MBP 14.1.0 Darwin Kernel Version 14.1.0
    Mon Dec 22 23:10:38 PST 2014
    root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Comment 1 sh.naz 2015-03-26 13:09:34 UTC
The same bug occurs when used in a grid layout, where the button is stretched automatically without setting the WidtRequest explicitly.
Comment 2 Ram Chandra 2015-03-27 05:36:13 UTC
I have checked this issue and I am able to reproduce this issue.

I observed that when we set WidthRequest property of button the text shows centers within the available width, but the image shows to the left of screen and when we don't set the WidthRequest property, it shows text next to the image.

Screencast: http://www.screencast.com/t/1PTv4mn6K57d
IDE logs: https://gist.github.com/RamChBachkheti/ff8530f4c46bcf8cdad1

Environment Info:

Xamarin.Forms: 1.4.1.6347-pre2

=== Xamarin Studio ===

Version 5.8.2 (build 5)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.Mac ===

Version: 2.1.0.273 (Enterprise Edition)

=== Xamarin.Android ===

Version: 4.20.1.0 (Enterprise Edition)
Android SDK: /Users/jatin66/Desktop/Backup/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 8.8.2.4 (Enterprise Edition)
Hash: 981acb3
Branch: 
Build date: 2015-03-25 14:21:05-0400

=== Build Information ===

Release ID: 508020005
Git revision: 541c06a4f6c95383333375d56fd6c23ce48cb916
Build date: 2015-03-20 09:23:08-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

=== Operating System ===

Mac OS X 10.10.0
Darwin Dalvik.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Jason Smith [MSFT] 2015-05-27 17:44:37 UTC
This is a limitation of the way Android handles button drawables.