0

I have a view and I have two Material Textfields in it. The problem is when I have to show detail Message or when the I click on text field the placeholder moves up. So if the space between fields is less then the animated placeholder text gets overlapped with above text field.

So far I have kept enough space between fields to rid of this issue but it does not look good moreover, in Android when the user clicks on the textfield and its animated text shows the textfield automatically moves some points down or up to cater the inner spacing issue.

Default View with without detail message and placeholder

placeholder and error message

Muhammad Nayab
  • 1,612
  • 14
  • 14
  • You can adjust `placeholderVerticalOffset` on the texfields – Orkhan Alikhanov Jul 27 '18 at 11:05
  • I know that but I want it to animate. placeholderVerticalOffset will have an impact on the distance between placeholder and TextField when animated – Muhammad Nayab Jul 27 '18 at 11:35
  • You want to move the `textField` down with animation when it is first responder or has text? – Orkhan Alikhanov Jul 27 '18 at 11:39
  • @OrkhanAlikhanov when it becomes first responder. Main purpose is to accommodate the "animated PlaceHolder". Otherwise it overlaps with other text fields – Muhammad Nayab Jul 27 '18 at 11:40
  • How do you layout the textFields? Probably using autolayout? Can you share code? – Orkhan Alikhanov Jul 27 '18 at 11:41
  • I am using storyboard. So the constraints are set on storyboard. Basically Trailing left, right, Top space and then Fixed Height – Muhammad Nayab Jul 27 '18 at 11:42
  • So your password field has top constraint from username field. You can bind that constraint to the file via `@IBOOutlet`, update the `constraint.constant` and animate it. See [this](https://stackoverflow.com/questions/12622424/how-do-i-animate-constraint-changes). – Orkhan Alikhanov Jul 27 '18 at 11:46
  • BTW, I would avoid giving fixed height constraint to the textFields as it creates unnecessary space between `placeholderLabel` and `textField` itself. – Orkhan Alikhanov Jul 27 '18 at 11:47
  • yes I have that in mind and I was also thinking about that. But I thought there might be other ways as well. – Muhammad Nayab Jul 27 '18 at 11:47

0 Answers0