[TIMOB-25926] Android TextField padding not applied with SDK 7.0.1
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | 7.0.1, engReviewed, padding, sdk-7.0.0 |
Reporter | Sandro Lain |
Assignee | Shak Hossain |
Created | 2018-01-22T16:39:04.000+0000 |
Updated | 2019-05-21T16:57:45.000+0000 |
Description
241/5000
The settings of the "padding" property (top, bottom, left, right) in the TextFields are not applied in the SDK 7.0.1. In SDK 6.3.0, the style is applied correctly.
I enclose two screenshots of the same code in SDK 6.3.0 and SDK 7.0.1.
The code for the TextField style into .tss file.
"#field_input": {
width: "100%",
height: 28,
top: 0,
textAlign: "center",
backgroundColor: "transparent",
color: "#FFFFFF",
font: {
fontFamily: "Roboto",
fontSize: 14
},
paddingLeft: 0,
paddingRight: 0,
padding: {
top: 0,
bottom: 0,
left: 0,
right: 0
},
borderWidth: 1, borderColor: "#F0F"
}
Attachments
File | Date | Size |
---|---|---|
SDK_6.3.0.png | 2018-01-22T16:36:48.000+0000 | 114032 |
SDK_7.0.1.png | 2018-01-22T16:36:48.000+0000 | 106031 |
Hello [~sandrolain], I see your Textfield height is hard-coded to 28. Which isn't a good idea since font size is hard-coded too. This makes a bad assumption about the OS theme that is applied to the TextField and what decoration might be applied. Try changing the TextField's "height" to Ti.UI.SIZE. I have tested this and it's working fine. Thanks.
Thanks, it was one of my tests and in other works I did so, but unfortunately for this application the graphics have been defined by a third company paid by my client, and I have to respect the proportions of the UI that I have been given.
[~sandrolain], I don't consider this a bug. Let me explain... In Titanium 7.0.0, we switched to using Google's newest material themed TextFields and TextAreas. These updated UI views from Google have more space above and below the editable area to make room for a top hint text, bottom underline, and bottom description text. Have a look at Google's "Input text" section and note that they've added "8dp" of *+internal+* padding above and below the editable field. This is not the same as the outer padding you're setting. (There's a picture showing this in the link below.) https://material.io/guidelines/components/text-fields.html#text-fields-layout So, the issue here is that your code is making a bad assumption about the space needed for the theme and UI decorations around the TextField, which is a portability issue between platforms and even different themes on the same platform (such as Android). You should never set both the TextField height and font size. Ideally, you should always the TextField height to Ti.UI.SIZE and it'll always correctly size to just-fit the field's contents and custom font you give it. Note that this is why Titanium offers vertical and horizontal layout features and the ability to auto-size UI. This is needed to display UI correctly between differently platforms and system themes. This is probably not the answer you want to hear, but it is a portable future-proof solution.
Hi, I have now done to make the adaptive height of the text field without specifying a fixed, as recommended, but if it were possible to specify a height as on iOS I could meet the rules of UI indicated by my client. The documentation indicates that on Android SDK 6.0.0 is available the property "padding" as for iOS, and actually in SDK 6.x.x I have already used it without problems. It should be reimplemented into SDK Android to respects it, or update the documentation indicating that with 7.x is no longer supported. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TextField-property-padding
[~sandrolain], the "padding" feature does work on Android, but it's an external padding. If you set it to something large such as...
...then you'll see that the above works. The issue is that Google's material themed TextFields also has an internal padding now that is separate from the external padding. If you look at the "material" theme guide I showed you, you can see this. That's the change here. If you're not willing to use Ti.UI.SIZE, then I recommend that you set the fontSize smaller on Android.
[~sandrolain], Did you manage to try the recommended steps?
Hi, I used height = Ti.UI.SIZE on android and it works as expected, but at the moment it does not solve the problem because from my client's graphic studio I have very specific dimensions, padding and font-size directives that I can not ignore
[~topener], What is that minimum padding number? 50? Should I include the following in https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TextField-property-padding "Android sets it's own minimum padding automatically. If you attempt to set anything below 50, it will not be reflected in your app."
[~bimmel] 50 is too big. [~jquick] can probably answer that question
Let's punt on this.
Yes I have same problem too.