There is a given element of the screen. Tags are located in the FlowLayout container (third-party library), which automatically transfers items to another row if they do not fit. The problem is that I need to display only 1 line of tags, and when I click on "more", I can display the rest. Maybe someone has an idea how to solve this problem.

enter image description here

Tagging methods

  private void createTag(Context context, FlowLayout container, TagEntity tagEntity){ TextView txt = (TextView) LayoutInflater.from(context) .inflate(R.layout.tag_view, null); String tagText=tagEntity.getName(); if (tagText.length()>9){ txt.setText(tagText.substring(0,9)+"..."); } else{ txt.setText(tagEntity.getName()); } txt.setBackgroundResource(tagEntity.getTagGroup().getColor()); FlowLayout.LayoutParams fl =new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT ); fl.setMargins(16,16,16,16); container.addView(txt,fl); } private void createTagFromList(Context context,FlowLayout container,List<TagEntity> list){ for (TagEntity tagEntity :list){ createTag(context,container, tagEntity); } } 
  • If you yourself have not found a way - then at least provide a link to the lib. - JuriySPb

1 answer 1

What if the element is set to a fixed height, and when you click on the "more" button, add the required amount of dp (change height)?

PS Just in case, to convert the height from dp to int for software use, you can call the method

 int valueInPixels = (int) context.getResources().getDimension(R.dimen.yourValueInDp);