java - Making 2 dynamic TextViews not overlap -
i have been working on app shows statuses server. have cardview each server, relativeview inside. on left image, aligned cards left. in middle, have textview, aligned image right. on right, have textview, aligned right of card.
basically, issue is, without using linearlayout, how can make middle textview not overlap right textview, preferably in layout's xml? text in both views dynamically long, making linearlayout not preferable.
here diagram of layout picture i'm talking about. sorry external link, getting reformatted in post.
i figured out how programatically. simply, want subtract widths , padding of surrounding views size of container view, , set leftover value text view's width. here example:
int view_length = personviewholder.container.getwidth() - personviewholder.container.getpaddingstart() - personviewholder.container.getpaddingend(); view_length = view_length - personviewholder.object_to_left.getwidth() - personviewholder.object_to_left.getpaddingstart() -personviewholder.object_to_left.getpaddingend(); view_length = view_length - personviewholder.object_to_right.getwidth() - personviewholder.object_to_right.getpaddingstart() - personviewholder.object_to_right.getpaddingend(); personviewholder.view_to_set_width.getlayoutparams().width = view_length; personviewholder.view_to_set_width.invalidate();
Comments
Post a Comment