安卓textview 超出部分省略号 ellipsize
1,设置singleLine,或lines,或maxLines设置ellipsize
2,设置了仍无效,因为我在代码中用了
text_three.setMovementMethod(ScrollingMovementMethod.getInstance());
造成了无效
3,判断是否省略
int xxlLines=text_three.getLineCount();
if(xxlLines>0){
//这里先getLayout,getEllipsisCount,参数是行,指那一行省略的字数,注释也的是
/**
* Returns the number of characters to be ellipsized away, or 0 if
* no ellipsis is to take place.
*/
int xxlEllipsisOnLastLine=text_three.getLayout().getEllipsisCount(xxlLines-1);
if(xxlEllipsisOnLastLine>0){
xxmLinearLayout_tips_more.setVisibility(View.VISIBLE);
}else{
xxmLinearLayout_tips_more.setVisibility(View.GONE);
}
}
4,也可以设置是否展开setEllipsize(TextUtils.TruncateAt.END)
setEllipsize(null)
页:
[1]