Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align View vertically to the text inside TextView?

Tags:

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. See images with case #1/#2 for reference.

Is it possible to achieve item 4 in XML? What about programmatically?

[Additional info]

Autosizing doesn't work properly with width wrap_content, see autosizing documentation:

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.