E electro179 Active Member Licensed User Longtime User Nov 18, 2015 #1 Hi How to set a padding in the textfield ? thank you
Erel B4X founder Staff member Licensed User Longtime User Nov 18, 2015 #2 You can use this sub: B4X: Sub SetPadding(tf As TextField, Padding As Float) Dim pnl As Panel pnl.Initialize("") pnl.SetLayoutAnimated(0, 1, 0, 0, Padding, tf.Height) Dim no As NativeObject = tf no.SetField("leftView", pnl) no.SetField("leftViewMode", 3) End Sub (It is based on this answer: http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone) Upvote 0
You can use this sub: B4X: Sub SetPadding(tf As TextField, Padding As Float) Dim pnl As Panel pnl.Initialize("") pnl.SetLayoutAnimated(0, 1, 0, 0, Padding, tf.Height) Dim no As NativeObject = tf no.SetField("leftView", pnl) no.SetField("leftViewMode", 3) End Sub (It is based on this answer: http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone)
S sorex Expert Licensed User Longtime User Mar 2, 2016 #4 Is this only valid code for textfields? When I change it to label and feed it with a label I get this error [<UILabel 0x165b2920> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key leftView. Upvote 0
Is this only valid code for textfields? When I change it to label and feed it with a label I get this error [<UILabel 0x165b2920> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key leftView.
S sorex Expert Licensed User Longtime User Mar 2, 2016 #5 I'm in need for top padding tho. worst case I go with an extra panel as container for the label. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 2, 2016 #6 There is no padding property to labels. Upvote 0