I have to display the Textview
in Android getting from xml
feed.
Let us take this is my Textview
:
Mallika Sherawat's upcoming movie Dirty Politics
Here I have created the layout dynamically for these Textview
:
LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 50);
textLayoutParams.gravity = Gravity.CENTER;
TextView tv = new TextView(this);
tv.setSingleLine(false);
tv.setEllipsize(null);
tv.setHorizontallyScrolling(false);
tv.setTextColor(Color.parseColor("#a7a9ac"));
tv.setText(Appscontent.Sub_arraylisttwo.get(j));
tv.setLayoutParams(textLayoutParams);
tv.setBackgroundColor(Color.parseColor("#414042"));
I have mentioned the width 50 here.
So the text is displayed well on small content Textview
.some time I have more content Textview
which means how can I display the Textview
like below:
Mallika Sherawat's
upcoming movie Dirty...
I mean the text is have to display maximum 2 lines only after the text is extended means simply add the ...
content like above example. How can I do this?
Try with:
tv.setMaxLines(2);
tv.setEllipsize(TextUtils.TruncateAt.END);