San
San

Reputation: 2088

Dynamic RowHeight in Custom Listview

I have been working on a project where all the recent user activities would be displayed in a custom textview. Please refer the following screenshot which is taken from Fancy App:

Fancy Activity Page

I am interested in knowing how they have achieved

1.The small left arrow icon in the listview. Is it a background that they have used in this layout ?

2.Dynamic Height View for every comment.

3.They have 4 text views for each row item : first one is for username, second one is for "commented on" and third one is for the product. If the product's name is too long, it adjusts itself and aligns accordingly. How do I place the text views to achieve this view ?

Upvotes: 1

Views: 129

Answers (2)

Sagar Shah
Sagar Shah

Reputation: 4292

1.The small left arrow icon in the listview. Is it a background that they have used in this layout ?

Yes It can be achive through taking background image with arrow. Layout will be stretch according to its contents but you can manage it by limiting contents with fix lines or something textviews or you can use NinePatchImage in background.

2.Dynamic Height View for every comment.

You can have this by taking relative layout or Linearlayout. May be It doesn't matter. You have to set the image to center horizontal/vertical as per it suits our requirements. Or TextView's max Lines to 4/5/ anything you like that best suits.

3.They have 4 text views for each row item : first one is for username, second one is for "commented on" and third one is for the product. If the product's name is too long, it adjusts itself and aligns accordingly. How do I place the text views to achieve this view ?

In this case you can take only 2 TextViews.

  • 1st TextView take userName dynamically with appending String "commented on" with appending product Name dynamically.

  • 2nd TextView shows descriptions with max Lines attributes if want. Otherwise Its ok.

Upvotes: 0

x90
x90

Reputation: 2170

They have custom layout for list item which contains ImageView and 2 TextViews (you can highlight part of text with spanables). So first textview holds username + commented on + topic and they highlight dynamic text. Background for item - nine-patch with triangle in top|left.

Upvotes: 2

Related Questions