Monday, 29 October 2018

How to align View vertically to the text inside TextView?

I'm trying to achieve this result:

Expected result

What I have right now it is ConstraintLayout which includes three Views: TextView, ImageView, ImageView

Design requirements:

  1. Text centered inside TextView;
  2. TextView has fixed size 80dp
  3. Size of text should be AutoSizeable;
  4. ImageViews should change position horizontally depending on text position inside TextView; (check images with case #1/#2)

The main problem here it is item #4. And my question is - Is it possible to do it in XML? Or how to do it programmatically?

[Additional info] Autosizing doesn't work properly with width wrap_content. From documentation Autosizing:

Note: If you set autosizing in an XML file, it is not recommended to use the value "wrap_content" for the layout_width or layout_height attributes of a TextView. It may produce unexpected results.



from How to align View vertically to the text inside TextView?

No comments:

Post a Comment