[TIMOB-20357] Android: 9-patch padding box area ignored for Button backgroundImage
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | 9patch, android, button, engSchedule |
Reporter | Andrey Tkachenko |
Assignee | Unknown |
Created | 2016-02-03T22:00:11.000+0000 |
Updated | 2019-11-15T16:00:35.000+0000 |
Description
From doc [Nine-patch](http://developer.android.com/intl/ru/guide/topics/graphics/2d-graphics.html#nine-patch):
The pink rectangle in the bottom image identifies the region in which the contents of the View are allowed.
If the contents don't fit in this region, then the image will be stretched so that they do.
But it ignored:
<Button backgroundImage="/images/alert_button.png">Блокировать</Button>
Result:
!2016-02-04 00-57-18 Genymotion for personal use - Google Nexus 4 - 4.2.2 - API 17 - 768x1280 (768x1280, 320dpi) - 192.168.5.png|thumbnail!
xhdpi Image source:
!alert_button.9.png|thumbnail!
Attachments
File | Date | Size |
---|---|---|
2016-02-04 00-57-18 Genymotion for personal use - Google Nexus 4 - 4.2.2 - API 17 - 768x1280 (768x1280, 320dpi) - 192.168.5.png | 2016-02-03T21:58:05.000+0000 | 4368 |
alert_button.9.png | 2016-02-03T21:53:21.000+0000 | 763 |
expected_button.png | 2016-02-04T11:37:22.000+0000 | 6795 |
patch.diff | 2016-02-04T20:04:08.000+0000 | 1378 |
patched_button.png | 2016-02-04T20:06:14.000+0000 | 2018 |
Screenshot_1509643799.png | 2017-11-02T17:30:09.000+0000 | 34511 |
Hello, I tried to test your project with SDK 5.1.2.GA. I have tested in Alloy and Classic project. In both case the image is stretched to allow the content. As I have not defined any width of the button and button has default SIZE behavior of it's content. The background image stretched according to the size of the text.
Thanks.
Hello! Can you to attach your screenshot? I expect this view of button: !expected_button.png|thumbnail!
I found a bug. Look at the [^patch.diff]. And patched button result: !patched_button.png|thumbnail! Android SDK reference: http://developer.android.com/intl/ru/reference/android/R.attr.html#padding
Quick fix till bug fixed: 1. Remove *backgroundColor* and *backgroundImage* attributes from style and alloy *
[~falko] PR on the master branch is welcomed. Please proceed. [^patch.diff] looks okay.
@Ashraf Abu [PR](https://github.com/appcelerator/titanium_mobile/pull/7696)
PR https://github.com/appcelerator/titanium_mobile/pull/7696 merged.
Please reopen this issue.
Result: https://yadi.sk/i/8OAGo0Waqg8Ne alert_button2.9.png https://yadi.sk/i/ZbNwXGY2qg8Th
I see. The blue arrows shouldn't be behind the text? But what would happen if you used this in a native app and have no space for the button as well as have a long text. Would the result be the same?
I think it is TiUIView issue.
Result: !https://1.downloader.disk.yandex.ru/disk/d8a004c7ca54ee4cdb9079e74612cc58308f99e8cfb9d7aba63f6a21e6e05b95/570270df/iXTtIy0Erdd2yuvf9sL5sX02OtRTrVwAupnyqqsMuSOiVPF6lgMcXbhgdZNfaZ1ulQd5oydfTnOAXjfHMGYMyg%3D%3D?uid=0&filename=2016-04-04_12-48-05.png&disposition=inline&hash=&limit=0&content_type=image%2Fpng&fsize=12540&hid=f1905293b1f03d012ac398b7662ac07c&media_type=image&tknv=v2&etag=1ccc13a3d39a27312ed2edc7e4f6dc8e! https://yadi.sk/i/ga5hSYBaqiaFA
I see. Reopening this ticket.
Can't find images from broken links. Please use my test code without modifications.
[~falko] I don't have access to
alert_button2.png
I did, and could not see any issues
I can't attaching a files. Please use for test one of resource set from link. It is good for test. https://yadi.sk/d/YgixO6033PQFK5 https://yadi.sk/i/QlC-fAF23PQFEa That's ok if your button text will be inside content body. Thx.
PR: https://github.com/appcelerator/titanium_mobile/pull/9999
Wow don't believe to my eyes! Good news, good PR number =)
[~ybanev] Can you take a quick look at this? I cannot see the issue.
[~ahutton] The issue is still a valid one. Unfortunately the solution in the PR for it requires a major change in how we deal with backgrounds for components.